[Home]Mandatory Options - Program Options Suggestion

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Difference (from prior major revision) (no other diffs)

Added: 54a55,67
The only thing is, how to allow the user to specify this format? Perhaps with:


options_description desc("Usage: %progname% %args% OPTIONS\n"
" MANDATORY OPTIONS:\n"
"%mandatory_options%"
" OPTIONS:\n"
"%optional_options%");


This could be the default -- if desc() is passed nothing.



Mandatory options

Back to Suggestions - program options library


A mandatory option facility would be useful. In the same way that "+" signifies a multi-argument parameter, so "!" could signify a mandatory paramter. Mandatory paramters would be shown on the command-line. For example, suppose we did:

    options_description desc("Usage: %progname% %args% OPTIONS\n"
                             "        OPTIONS");

    desc.add_options()
        ("-a", "arg1!", "some argument")
        ("-b", "arg2!", "some other argument")
        ("-v", "val", "some value")
        ("-w", "word", "some other value")
        ;

We'd get the usage message:

    Usage: someprogram -a arg1 -b arg2 <files> OPTIONS
            OPTIONS:
        -a arg1 : some argument
        -b arg2 : some other argument
        -v val  : some value 
        -w word : some other vlue

    - People/Chuck Messenger


That's usefull feature. I only think that putting mandatory features in the place you propose is not good idea: there can be several of them, and it would be hard to nicely format them. Probably, something like:

    Usage: someprogram <files> OPTIONS
           MANDATORY OPTIONS:
        -a arg1 : some argument
        -b arg2 : some other argument
            OPTIONS:
        -v val  : some value 
        -w word : some other vlue

   - People/Vladimir Prus


Yes -- I like that.

The only thing is, how to allow the user to specify this format? Perhaps with:

    options_description desc("Usage: %progname% %args% OPTIONS\n"
                             "        MANDATORY OPTIONS:\n"
                             "%mandatory_options%"
                             "        OPTIONS:\n"
                             "%optional_options%");

This could be the default -- if desc() is passed nothing.

    - People/Chuck Messenger



BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited May 22, 2003 12:31 pm (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers