forked from microsoft/xlang
-
Notifications
You must be signed in to change notification settings - Fork 2
option
Raymond Chen edited this page Mar 30, 2019
·
1 revision
The xlang::cmd::option structure is defined in cmd_reader.h and defines a single command line option. It is typically constructed as part of a static constexpr array that defines the program's command line options.
To create an option, use aggregate initialization
option{ name, min, max, arg, desc }
| Member | Type | Default | Meaning |
|---|---|---|---|
name |
std::string_view |
Required | The name of the command line option, no leading hyphen. Command line options are case-sensitive. |
min |
uint32_t |
no_min = 0 |
The minimum number of arguments accepted by this option. |
max |
uint32_t |
no_max = unlimited |
The maximum number of arguments accepted by this option. |
arg |
std::string_view |
""sv |
App-defined value, traditionally used to describe the supported arguments. |
desc |
std::string_view |
""sv |
App-defined value, traditionally used to describe what the option does. |
The symbolic names option::no_min and option::no_max can be used for min and max.
The xlang library does not use arg or desc, but it provides a convenient place for apps to include information that they can print as part of their usage string.
for (auto const& option : options)
{
printf("-%s %s\n", option.name.data(), option.arg.data());
printf(" %s\n", option.desc.data());
}