forked from Alepha/Alepha
Online documentation for single-letter options.
It's mostly worked out, but there's a few odd corner cases, especially around the auto-gen of negation options. It also got me to start thinking about "is a required negatable option still required of its negation?" Similar questions revolve around requiring such options. I'm punting on these for now, but I think it makes sense to perhaps make those incompatible with such domains. Or to treat the two options as a shared-fate unit. But is `-O -o -O -o` a violation of exclusivity? If we wind up returning to the default state, have we actually passed that option, with respect to "requirement"? I have to think about that some more. A commit message isn't the best place to capture this, but I didn't want to lose this thought.
This commit is contained in:
14
example.cc
14
example.cc
@ -16,11 +16,16 @@ namespace
|
||||
|
||||
bool optionC= false;
|
||||
|
||||
const Alepha::RequirementDomain need;
|
||||
const Alepha::ExclusivityDomain block;
|
||||
//const Alepha::detail::ProgramOptions_m::Domain< nil > need;
|
||||
//const Alepha::detail::ProgramOptions_m::Domain< nil > block;
|
||||
|
||||
auto init= enroll <=[]
|
||||
{
|
||||
--"set-a"_option << optionA << "The option is an integer. !default!";
|
||||
--"set-b"_option << optionB << "The option is a string, no defaults.";
|
||||
--"set-c"_option << optionC << "This sets the 'C' flag.";
|
||||
--"set-a"_option << need << optionA << "The option is an integer. !default!";
|
||||
--"set-b"_option << block << optionB << "The option is a string, no defaults.";
|
||||
--"set-c"_option << block << need << optionC << "This sets the 'C' flag.";
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,7 +33,8 @@ int
|
||||
main( const int argcnt, const char *const *const argvec )
|
||||
try
|
||||
{
|
||||
const auto args= Alepha::handleOptions( argcnt, argvec, { { 'c', "set-c" }, { 'C', "no-set-c" } } );
|
||||
const auto args= Alepha::handleOptions( argcnt, argvec, { { 'c', "set-c" }, { 'C', "no-set-c" }, { 'D', "dump-color-env-var" },
|
||||
{ 'L', "list-color-variables" }, } );
|
||||
|
||||
std::cout << "A is set to: " << optionA << std::endl;
|
||||
std::cout << "B is set to: " << ( optionB.has_value() ? optionB.value() : "nullopt"s ) << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user