Skip to content

coalesced flags with final one being an option don't work #108

@wreedb

Description

@wreedb
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 foo

does not work; 'foo' becomes an unexpected token, but:

./demo -vd -n foo

works 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions