Lyra icon indicating copy to clipboard operation
Lyra copied to clipboard

choices() with a single string literal does not work

Open mknejp opened this issue 8 months ago • 0 comments

When calling choices("foo") it appears the array overload is preferred, leading to the value not being accepted.

auto choice = std::string{};
cli.add_argument(
  lyra::opt(choice, "your choice")
    .name("--choice")
    .choices("foo")                // does not work
    //.choices(std::string{"foo"}) // does work
    .required());

When called with ./a.out --choice foo it causes the error Unable to convert 'foo' to destination type

Demonstration: https://godbolt.org/z/YWvY3a96x

mknejp avatar Jun 03 '24 14:06 mknejp