Boost C++ Libraries: Ticket #342: program_options Can one have options with optional values? https://svn.boost.org/trac10/ticket/342 <pre class="wiki">Hello, I was wondering if it is possible to have an option for which supplying an argument is optional. For example, suppose I have an executable called myprog and an option "o" that does something. Is it possible to allow both of the following command line syntaxes? myprog --o arg myprog --o Where in the second case I can programatically supply some default value? So the first would instruct the program to take the action associated with the "o" option using the supplied arg and the second would instruct it to take that action using the default argument value. I have been fooling with the default_value and implicit methods but neither seems to do what I want. Thanks, John Eddy johneddy@eng.buffalo.edu </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/342 Trac 1.4.3 rleigh@… Mon, 28 May 2007 14:42:38 GMT <link>https://svn.boost.org/trac10/ticket/342#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/342#comment:1</guid> <description> <p> This is a feature I would also find most useful. In my case, I would like to have an option: </p> <blockquote> <p> --run-session </p> </blockquote> <p> but also allow the user to specify an optional session name </p> <blockquote> <p> --run-session=session-name </p> </blockquote> <p> and if this is missing, I will compute one automatically. </p> <p> GNU getopt_long has the concept of "required" and "optional" arguments. It would be nice if typed_value/value_semantic had an optional() method and member to permit this. </p> <p> Regards, Roger </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daryle Walker</dc:creator> <pubDate>Fri, 03 Aug 2007 11:52:25 GMT</pubDate> <title>component changed; severity set https://svn.boost.org/trac10/ticket/342#comment:2 https://svn.boost.org/trac10/ticket/342#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">program_options</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket Vladimir Prus Sun, 05 Aug 2007 18:41:49 GMT status, resolution changed https://svn.boost.org/trac10/ticket/342#comment:3 https://svn.boost.org/trac10/ticket/342#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">duplicate</span> </li> </ul> <p> Superseded by <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1131" title="#1131: Patches: program_options patch: optional argument support (gnu getopt_long style) (closed: fixed)">#1131</a>. </p> Ticket