bfgroup / Lyra

A simple to use, composable, command line parser for C++ 11 and beyond
https://bfgroup.github.io/Lyra/
Boost Software License 1.0
471 stars 56 forks source link

choices() with a single string literal does not work #90

Open mknejp opened 3 months ago

mknejp commented 3 months ago

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