Skip to content

Implicit values break value assignment without equals sign #441

@blackworm27

Description

@blackworm27

I am trying to allow the following kind of command line uses:

  1. <option not specified> yields default value (e.g., {""})
  2. --option with no argument yields implicit value (e.g., {"all"})
  3. --option a yields {"a"}
  4. --option a --option b yields {"a", "b"}

Instead, #3 yields {"all"} and #4 yields {"all", "all"}. It seems using implicit_value forces the user to use the --option=a,b syntax. Is this intended?

Here is my code fragment. I am using v3.2.1.

    _currentOptions->add_options()(
        "option",
        "description",
        cxxopts::value<std::vector<std::string>>()->default_value("")->implicit_value("all"));

Thank you for any guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions