-
-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
using namespace lyra;
bool fooinvoked = false;
bool showfoohelp = false;
bool showhelp = false;
bool verbose = false;
bool dryrun = false;
std::string name;
auto cli
= help(showhelp)
| command("foo", [&](const group&) { foo_invoked = true; })
.add_argument(help(showfoohelp))
.add_argument(opt(verbose)["-v"]["--verbose"]("display more output").optional())
.add_argument(opt(dryrun)["-d"]["--dry-run"]("simulate actions").optional())
.add_argument(opt(name, "NAME")["-n"]["--name"]("specify a name").optional());
auto result = cli.parse({argc,argv});
if (fooinvoked) {
if (!name.empty()) std::cout << "name: " << name << "\n";
std::cout << "verbose: " << verbose << "\n";
std::cout << "dryrun: " << dryrun << std::endl;
}
given the above snippet, running:
./demo -vdn foodoes not work; 'foo' becomes an unexpected token, but:
./demo -vd -n fooworks still; the coalescing works perfectly, unless the final option takes a value.
I've been considering replacing CLI11 in my project with Lyra, however this caught me in my tracks; is this intentional behavior?
Metadata
Metadata
Assignees
Labels
No labels