Skip to content

v0.0.128: [Util] Extend `ArgParser` to support lists.

Compare
Choose a tag to compare
@mirror-releases mirror-releases released this 26 Oct 12:07
· 458 commits to main since this release
36fd3fd
Extend the `ArgParser` to support CLI arguments with lists of strings.
For example, one can now implement an argument like
```
--colors "yellow,green,navy blue,pink"
```
The type of the argument must be `std::vector<std::string_view>`.

To implement such a CLI argument in our shell, you can do
```cpp
ADD(std::vector<std::string_view>, void *_, nullptr,
    nullptr, "--colors",
    "A comma-separated list of colors.",
    [&](std::vector<std::string_view> colors) {
        std::cerr << "received colors are:\n";
        for (auto color : colors) std::cerr << "  " << color << '\n';
});
```