From 4611e693cad7acb300f7237a77e396be8fbfe8fb Mon Sep 17 00:00:00 2001 From: clockblocker Date: Sat, 14 Nov 2026 06:40:19 +0100 Subject: [PATCH] Add rfl::cli::ListDelimiter to change or turn off list splitting rfl::cli splits list values at commas, so an item cannot contain one. ListDelimiter<";"> splits at ';' instead, and ListDelimiter<""> does not split: each occurrence of a list option, and each positional argument of a list, is then exactly one item, even if it is empty. The setting applies to every list of the struct; other fields are never split. The delimiter is a single ASCII character, which a static_assert checks. Like rfl::cli::AllowAbbreviations it is a processor that only rfl::cli looks at: read passes it to the Reader, which splits each occurrence with it, and usage shows ``, or `` without splitting. Co-Authored-By: Claude Opus 5.5 --- docs/content/supported_formats/cli.md | 28 +++++- include/rfl/cli.hpp | 1 + include/rfl/cli/ListDelimiter.hpp | 91 +++++++++++++++++++ include/rfl/cli/Reader.hpp | 77 +++++++++------- include/rfl/cli/read.hpp | 5 +- include/rfl/cli/usage.hpp | 53 ++++++----- tests/cli/test_list_delimiter.cpp | 121 ++++++++++++++++++++++++++ tests/cli/test_usage_options.cpp | 41 +++++++++ 8 files changed, 364 insertions(+), 53 deletions(-) create mode 100644 include/rfl/cli/ListDelimiter.hpp create mode 100644 tests/cli/test_list_delimiter.cpp diff --git a/docs/content/supported_formats/cli.md b/docs/content/supported_formats/cli.md index 3b1df7b4..425afd8c 100644 --- a/docs/content/supported_formats/cli.md +++ b/docs/content/supported_formats/cli.md @@ -288,6 +288,28 @@ Any other option can be given only once. That includes nested fields and map entries: `Duplicate argument: --output`, `Duplicate short argument: -o`, `Conflict: '-o' and '--output' both provided.` +### List delimiter + +`rfl::cli::ListDelimiter<"x">` splits lists at another character, and +`rfl::cli::ListDelimiter<"">` does not split them at all: + +```cpp +rfl::cli::read>(argc, argv); +// ./app --report='a;b' --report=c,d -> report = {"a", "b", "c,d"} + +rfl::cli::read>(argc, argv); +// ./app --report=a,b --report= -> report = {"a,b", ""} +``` + +- The delimiter is a single ASCII character, such as `;`, `:` or a space. + A longer one would make values such as `a;;;b` ambiguous; repeat the + option instead. +- It applies to every list option and list positional argument of the + struct. Other fields are never split. +- Without a delimiter, each occurrence, and each positional argument, is + exactly one item, even if it is empty. +- Other formats ignore it. + ### A list as the last positional argument If the last positional field (in declaration order) is a list, it takes all @@ -432,7 +454,10 @@ struct, is a flag whose value can be left out (`--verbose[=]`), a list takes comma-separated items and can be repeated (`--tags=`, with `Can be repeated.` in its row), a list as the last `rfl::Positional` takes the remaining arguments (`...`), and every other option takes a value -(`--port=`). +(`--port=`). With `rfl::cli::ListDelimiter<";">`, a list is +`--tags=` and its default is joined with `;`. With +`rfl::cli::ListDelimiter<"">`, it is `--tags=`, and its default is +left out, because one value cannot spell several items. `rfl::Positional` and `rfl::Short` are found through the other wrappers, as the parser does (see [Combining wrappers](#combining-wrappers)), so @@ -496,6 +521,7 @@ Parsing proceeds in three stages: - `include/rfl/cli/parse_argv.hpp` — `argv` -> `ParsedArgs` - `include/rfl/cli/options.hpp` — the internal option table: the long, short and positional options of a struct - `include/rfl/cli/AllowAbbreviations.hpp` — `AllowAbbreviations` processor +- `include/rfl/cli/ListDelimiter.hpp` — `ListDelimiter<"x">` processor - `include/rfl/cli/resolve_args.hpp` — `ParsedArgs` -> `map` - `include/rfl/cli/usage.hpp` — `usage()` help text, built on `rfl::parsing::schema` and the internal option table - `include/rfl/cli.hpp` — aggregator header diff --git a/include/rfl/cli.hpp b/include/rfl/cli.hpp index 8cedad7f..f69cb9fc 100644 --- a/include/rfl/cli.hpp +++ b/include/rfl/cli.hpp @@ -3,6 +3,7 @@ #include "../rfl.hpp" #include "cli/AllowAbbreviations.hpp" +#include "cli/ListDelimiter.hpp" #include "cli/Parser.hpp" #include "cli/Reader.hpp" #include "cli/SeparateOptionValues.hpp" diff --git a/include/rfl/cli/ListDelimiter.hpp b/include/rfl/cli/ListDelimiter.hpp new file mode 100644 index 00000000..9eb6ab05 --- /dev/null +++ b/include/rfl/cli/ListDelimiter.hpp @@ -0,0 +1,91 @@ +#ifndef RFL_CLI_LISTDELIMITER_HPP_ +#define RFL_CLI_LISTDELIMITER_HPP_ + +#include +#include +#include + +#include "../Processors.hpp" +#include "../internal/StringLiteral.hpp" + +namespace rfl::cli { + +/// A setting for rfl::cli::read that sets the character at which the values +/// of list options and list positional arguments are split into items. The +/// default is ",": `--report=a,b` gives two items. ListDelimiter<";"> +/// splits at ';' instead, and ListDelimiter<""> does not split, so every +/// value, and every positional argument, is exactly one item. The setting +/// applies to every list in the struct. +/// The delimiter is a single ASCII character, as in clap and CLI11. Several +/// characters would make the splitting of a value such as "a;;;b" with ";;" +/// ambiguous; repeat the option instead. +/// This is a marker type (doesn't modify data) that only rfl::cli::read looks +/// at. Other formats ignore it. +/// Usage: rfl::cli::read>(argc, argv) +template +struct ListDelimiter { + static_assert(_delimiter.length == 0 + || (_delimiter.length == 1 && _delimiter.arr_[0] != '\0' + && static_cast(_delimiter.arr_[0]) + < 0x80), + "rfl::cli::ListDelimiter takes a single ASCII character, " + "such as \";\", or \"\" to not split lists."); + + /// The character at which list values are split, or std::nullopt if they + /// are not split. + static constexpr std::optional delimiter = + _delimiter.length == 0 ? std::nullopt + : std::optional(_delimiter.arr_[0]); + + /// Identity process function - returns the named tuple unchanged. + /// @tparam StructType The struct type being processed + /// @param _named_tuple The named tuple representation of the struct + /// @return The same named tuple (unchanged) + template + static auto process(auto&& _named_tuple) { + return _named_tuple; + } +}; + +namespace internal { + +/// `count` is the number of ListDelimiters in T, and `value` the delimiter +/// of the one there is. +template +struct list_delimiter { + static constexpr size_t count = 0; + static constexpr std::optional value = std::nullopt; +}; + +template +struct list_delimiter> { + static constexpr size_t count = 1; + static constexpr std::optional value = + ListDelimiter<_delimiter>::delimiter; +}; + +template +struct list_delimiter> { + static constexpr size_t count = (list_delimiter::count + ... + 0); + static_assert(count <= 1, "Pass at most one rfl::cli::ListDelimiter."); + // The other processors have no value, so this is the one ListDelimiter's. + static constexpr char code = static_cast( + (list_delimiter::value.value_or('\0') + ... + 0)); + static constexpr std::optional value = + code == '\0' ? std::nullopt : std::optional(code); +}; + +/// The character at which the processors say to split list values (',', +/// rfl::cli::array_delimiter, by default), or std::nullopt if they are not +/// split (ListDelimiter<"">). +template +constexpr std::optional list_delimiter_v = + list_delimiter>>::count == 0 + ? std::optional(',') + : list_delimiter>>::value; + +} // namespace internal + +} // namespace rfl::cli + +#endif diff --git a/include/rfl/cli/Reader.hpp b/include/rfl/cli/Reader.hpp index ccee2207..c15b53b5 100644 --- a/include/rfl/cli/Reader.hpp +++ b/include/rfl/cli/Reader.hpp @@ -24,6 +24,7 @@ static constexpr char path_separator = '.'; /// Character used to delimit array elements in CLI argument values. /// Example: `--ports=8080,8081,8082` for an array of ports. +/// rfl::cli::ListDelimiter replaces it. static constexpr char array_delimiter = ','; namespace internal { @@ -31,7 +32,7 @@ namespace internal { /// The occurrences after the first of the list options given more than /// once, by path, in argv order. The argument map holds the first one: /// `--ports 80 --ports 81,82` is held as "80" in the argument map and -/// {"81,82"} here. Each occurrence is split at array_delimiter. +/// {"81,82"} here. Each occurrence is split at the list delimiter. using CliLaterOccurrencesType = std::map>; @@ -159,6 +160,13 @@ struct Reader { template static constexpr bool has_custom_constructor = false; + Reader() = default; + + /// @param _list_delimiter The character at which list values are split + /// into items, or std::nullopt to not split them, see ListDelimiter. + explicit Reader(const std::optional _list_delimiter) noexcept + : list_delimiter_(_list_delimiter) {} + /// Gets a specific element from a CLI array by index. /// @param _idx The index of the element to retrieve /// @param _arr The CLI array @@ -277,9 +285,9 @@ struct Reader { return parse_value(*str, _var.path); } - /// Converts a CLI variable to an array by splitting the value on commas. - /// The items of every occurrence of a repeated list option are added in - /// order (see internal::CliLaterOccurrencesType). + /// Converts a CLI variable to an array by splitting the value on commas, + /// or on the list delimiter. The items of every occurrence of a repeated + /// list option are added in order (see internal::CliLaterOccurrencesType). /// @param _var The CLI variable containing a comma-delimited string /// @return A Result containing a CliArrayType with the split values rfl::Result to_array( @@ -337,33 +345,6 @@ struct Reader { return it->second; } - /// Splits a list into its items: those of _first, the occurrence that - /// get_value returns for _var, then those of its later occurrences. - static std::vector split_items(const std::string& _first, - const InputVarType& _var) { - std::vector items; - add_items(_first, &items); - if (_var.direct_value || !_var.later_occurrences) { - return items; - } - const auto it = _var.later_occurrences->find(_var.path); - if (it != _var.later_occurrences->end()) { - for (const auto& occurrence : it->second) { - add_items(occurrence, &items); - } - } - return items; - } - - /// Adds the items of one occurrence of a list, split at array_delimiter, - /// to _items. - static void add_items(const std::string& _occurrence, - std::vector* _items) { - for (auto& item : split(_occurrence, array_delimiter)) { - _items->emplace_back(std::move(item)); - } - } - static std::vector split( const std::string& _str, char _delim ) { @@ -388,6 +369,40 @@ struct Reader { return result; } + /// Splits a list into its items: those of _first, the occurrence that + /// get_value returns for _var, then those of its later occurrences. + std::vector split_items(const std::string& _first, + const InputVarType& _var) const { + std::vector items; + add_items(_first, &items); + if (_var.direct_value || !_var.later_occurrences) { + return items; + } + const auto it = _var.later_occurrences->find(_var.path); + if (it != _var.later_occurrences->end()) { + for (const auto& occurrence : it->second) { + add_items(occurrence, &items); + } + } + return items; + } + + /// Adds the items of one occurrence of a list, split at the list + /// delimiter, to _items. Without a delimiter, the occurrence is one item, + /// even if it is empty. + void add_items(const std::string& _occurrence, + std::vector* _items) const { + if (!list_delimiter_) { + _items->push_back(_occurrence); + return; + } + for (auto& item : split(_occurrence, *list_delimiter_)) { + _items->emplace_back(std::move(item)); + } + } + + /// The character at which list values are split, see ListDelimiter. + std::optional list_delimiter_ = array_delimiter; }; } // namespace rfl::cli diff --git a/include/rfl/cli/read.hpp b/include/rfl/cli/read.hpp index 3c05beb3..3d90a4f8 100644 --- a/include/rfl/cli/read.hpp +++ b/include/rfl/cli/read.hpp @@ -7,6 +7,7 @@ #include "../Processors.hpp" #include "../SnakeCaseToKebabCase.hpp" +#include "ListDelimiter.hpp" #include "Parser.hpp" #include "Reader.hpp" #include "options.hpp" @@ -17,12 +18,14 @@ namespace rfl::cli { namespace internal { +static_assert(list_delimiter_v> == array_delimiter); + /// Resolves the parsed arguments and reads them into T. template rfl::Result read_parsed(ParsedArgs _parsed, const Options& _options) { return resolve_args(std::move(_parsed), _options) .and_then([](auto _args) -> rfl::Result { - const auto r = Reader(); + const auto r = Reader(internal::list_delimiter_v); const auto var = CliVarType{&_args.values, "", std::nullopt, &_args.later_occurrences}; return Parser::read(r, var); diff --git a/include/rfl/cli/usage.hpp b/include/rfl/cli/usage.hpp index 383b2092..87d36af1 100644 --- a/include/rfl/cli/usage.hpp +++ b/include/rfl/cli/usage.hpp @@ -32,6 +32,7 @@ #include "../parsing/schema/ValidationType.hpp" #include "../parsing/schema/make.hpp" #include "../to_generic.hpp" +#include "ListDelimiter.hpp" #include "Reader.hpp" #include "options.hpp" #include "resolve_args.hpp" @@ -156,11 +157,13 @@ inline std::string usage_number_to_string( /// Renders a default value the way it would be passed on the command line. /// Returns nullopt for values that cannot be rendered sensibly (null, /// objects, empty arrays). -/// Lists are joined with the list delimiter. +/// Lists are joined with the list delimiter. If lists are not split +/// (ListDelimiter<"">), a list of several items cannot be typed as one +/// value, so it is left out. inline std::optional usage_default_to_string( - const Generic& _value) { + const Generic& _value, const std::optional _delimiter) { return std::visit( - [](const auto& _v) -> std::optional { + [&](const auto& _v) -> std::optional { using V = std::remove_cvref_t; if constexpr (std::is_same_v) { return _v ? "true" : "false"; @@ -171,17 +174,17 @@ inline std::optional usage_default_to_string( } else if constexpr (std::is_same_v) { return _v.empty() ? std::string("\"\"") : _v; } else if constexpr (std::is_same_v) { - if (_v.empty()) { + if (_v.empty() || (!_delimiter && _v.size() > 1)) { return std::nullopt; } std::string joined; for (const auto& element : _v) { - const auto str = usage_default_to_string(element); + const auto str = usage_default_to_string(element, _delimiter); if (!str) { return std::nullopt; } if (!joined.empty()) { - joined += array_delimiter; + joined += *_delimiter; } joined += *str; } @@ -306,11 +309,13 @@ class UsageCollector { UsageCollector(const parsing::schema::Definition* _definition, const std::map* _meta, const Options* _options, - const bool _optionals_are_required) + const bool _optionals_are_required, + const std::optional _delimiter) : definition_(_definition), meta_(_meta), options_(_options), - optionals_are_required_(_optionals_are_required) { + optionals_are_required_(_optionals_are_required), + delimiter_(_delimiter) { for (const auto& [short_name, path] : _options->short_options) { short_names_[path] = short_name; } @@ -471,7 +476,7 @@ class UsageCollector { _arg.kind = option.kind; _arg.is_list = option.is_list; if (_default) { - _arg.default_value = usage_default_to_string(*_default); + _arg.default_value = usage_default_to_string(*_default, delimiter_); } args_.emplace_back(std::move(_arg)); } @@ -493,6 +498,7 @@ class UsageCollector { const std::map* meta_; const Options* options_; const bool optionals_are_required_; + const std::optional delimiter_; /// The rfl::Short aliases, by the path of their field. std::map short_names_; std::set visiting_; @@ -500,18 +506,21 @@ class UsageCollector { }; /// The placeholder for the value of _arg: "", "", or for a list -/// "" with the list delimiter. -inline std::string usage_value_to_string(const UsageArg& _arg) { - if (!_arg.is_list) { +/// "" with the list delimiter. If lists are not split +/// (ListDelimiter<"">), every occurrence is one item: "". +inline std::string usage_value_to_string(const UsageArg& _arg, + const std::optional _delimiter) { + if (!_arg.is_list || !_delimiter) { return _arg.value; } - const auto d = std::string(1, array_delimiter); + const auto d = std::string(1, *_delimiter); return ""; } /// "", "...", "-p|--port=", "--verbose[=]" inline std::string usage_arg_to_string(const UsageArg& _arg, - const std::string& _short_sep) { + const std::string& _short_sep, + const std::optional _delimiter) { if (_arg.positional) { // A list as the last positional field takes the remaining arguments. // Any other positional field takes one. @@ -520,7 +529,7 @@ inline std::string usage_arg_to_string(const UsageArg& _arg, auto str = _arg.short_name.empty() ? std::string() : "-" + _arg.short_name + _short_sep; str += "--" + _arg.name; - const auto value = usage_value_to_string(_arg); + const auto value = usage_value_to_string(_arg, _delimiter); switch (_arg.kind) { case OptionKind::flag: // `--verbose`: the value can be left out. @@ -579,10 +588,11 @@ inline std::string usage_help_text(const UsageArg& _arg) { inline std::string format_usage(const std::string& _program_name, const std::vector& _args, - const bool _detailed) { + const bool _detailed, + const std::optional _delimiter) { auto out = "Usage: " + _program_name; for (const auto& arg : _args) { - const auto str = usage_arg_to_string(arg, "|"); + const auto str = usage_arg_to_string(arg, "|", _delimiter); out += arg.required ? " " + str : " [" + str + "]"; } out += '\n'; @@ -593,7 +603,8 @@ inline std::string format_usage(const std::string& _program_name, auto rows = std::vector>(); size_t width = 0; for (const auto& arg : _args) { - rows.emplace_back(usage_arg_to_string(arg, ", "), usage_help_text(arg)); + rows.emplace_back(usage_arg_to_string(arg, ", ", _delimiter), + usage_help_text(arg)); width = std::max(width, rows.back().first.size()); } @@ -661,6 +672,7 @@ rfl::Result usage(const std::string& _program_name, const bool _detailed = false) { using ProcessorsType = Processors; using NamedTupleType = rfl::internal::processed_t; + constexpr auto delimiter = internal::list_delimiter_v; // The table that read() parses with, so the help shows what the parser // accepts, including the options inside nested structs and maps. const auto options = @@ -679,11 +691,12 @@ rfl::Result usage(const std::string& _program_name, ProcessorsType>(); auto collector = internal::UsageCollector( &definition, &meta, &options, - rfl::internal::no_optionals_v); + rfl::internal::no_optionals_v, delimiter); const auto args = collector.collect( rfl::internal::default_if_missing_v, internal::usage_defaults()); - return internal::format_usage(_program_name, args, _detailed); + return internal::format_usage(_program_name, args, _detailed, + delimiter); } catch (std::exception& e) { return error(e.what()); } diff --git a/tests/cli/test_list_delimiter.cpp b/tests/cli/test_list_delimiter.cpp new file mode 100644 index 00000000..67cfd862 --- /dev/null +++ b/tests/cli/test_list_delimiter.cpp @@ -0,0 +1,121 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace test_list_delimiter { + +template +rfl::Result read(std::vector _args) { + _args.insert(_args.begin(), "program"); + return rfl::cli::read(static_cast(_args.size()), + const_cast(_args.data())); +} + +template +std::string error_of(const rfl::Result& _result) { + return _result ? std::string("(no error)") + : std::string(_result.error().what()); +} + +using Strings = std::vector; + +struct Database { + std::optional hosts; +}; + +struct Opts { + rfl::Short<"t", std::optional> tags; + std::optional> ports; + std::optional> size; + std::optional name; + std::optional database; + std::optional> groups; + rfl::Positional> files; +}; + +using Semicolon = rfl::cli::ListDelimiter<";">; +using NoSplit = rfl::cli::ListDelimiter<"">; + +TEST(cli, test_list_delimiter_semicolon) { + const auto result = read( + {"--tags=a;b,c", "-t", "d", "--ports=80;81", "--size=3;4", + "--name=x;y", "f;g", "h,i"}); + ASSERT_TRUE(result) << result.error().what(); + const auto& o = result.value(); + EXPECT_EQ(o.tags(), (Strings{"a", "b,c", "d"})); + EXPECT_EQ(o.ports, (std::vector{80, 81})); + EXPECT_EQ(o.size, (std::array{3, 4})); + // Only lists are split. + EXPECT_EQ(o.name, "x;y"); + EXPECT_EQ(o.files(), (Strings{"f", "g", "h,i"})); +} + +TEST(cli, test_list_delimiter_applies_to_every_list) { + const auto result = read( + {"--database.hosts=a;b", "--groups.x=c;d"}); + ASSERT_TRUE(result) << result.error().what(); + const auto& o = result.value(); + ASSERT_TRUE(o.database); + EXPECT_EQ(o.database->hosts, (Strings{"a", "b"})); + EXPECT_EQ(o.groups, (std::map{{"x", {"c", "d"}}})); +} + +TEST(cli, test_list_delimiter_colon_and_space) { + const auto colon = + read>({"--tags=/usr/bin:/bin"}); + ASSERT_TRUE(colon) << colon.error().what(); + EXPECT_EQ(colon.value().tags(), (Strings{"/usr/bin", "/bin"})); + + // As with ',', empty items are skipped. + const auto space = read>( + {"--tags=a b c", "--tags= d", "x,y z"}); + ASSERT_TRUE(space) << space.error().what(); + EXPECT_EQ(space.value().tags(), (Strings{"a", "b", "c", "d"})); + EXPECT_EQ(space.value().files(), (Strings{"x,y", "z"})); +} + +TEST(cli, test_list_delimiter_empty_disables_splitting) { + const auto result = read( + {"--tags=a,b", "-t", "c;d", "--tags=", "x,y", "", "z w"}); + ASSERT_TRUE(result) << result.error().what(); + const auto& o = result.value(); + // Each occurrence and each argument is exactly one item, even if empty. + EXPECT_EQ(o.tags(), (Strings{"a,b", "c;d", ""})); + EXPECT_EQ(o.files(), (Strings{"x,y", "", "z w"})); + + const auto ints = read({"--ports=80", "--ports=81"}); + ASSERT_TRUE(ints) << ints.error().what(); + EXPECT_EQ(ints.value().ports, (std::vector{80, 81})); + EXPECT_NE(error_of(read({"--ports=80,81"})), "(no error)"); +} + +TEST(cli, test_list_delimiter_with_other_settings) { + for (const auto& result : + {read( + {"--tag=a;b", "c;d"}), + read( + {"--tag=a;b", "c;d"})}) { + ASSERT_TRUE(result) << result.error().what(); + EXPECT_EQ(result.value().tags(), (Strings{"a", "b"})); + EXPECT_EQ(result.value().files(), (Strings{"c", "d"})); + } + EXPECT_EQ(error_of(read({"--x=1"})), + "Unknown option '--x'."); +} + +// The trait that rfl::cli::read uses. +static_assert(rfl::cli::internal::list_delimiter_v> == ','); +static_assert(rfl::cli::internal::list_delimiter_v< + rfl::Processors> == ';'); +static_assert(!rfl::cli::internal::list_delimiter_v< + rfl::Processors> + .has_value()); + +} // namespace test_list_delimiter diff --git a/tests/cli/test_usage_options.cpp b/tests/cli/test_usage_options.cpp index 4cacd774..45152ebc 100644 --- a/tests/cli/test_usage_options.cpp +++ b/tests/cli/test_usage_options.cpp @@ -107,4 +107,45 @@ TEST(cli, test_usage_short_name_taken) { "Duplicate short name '-o' in struct definition."); } +TEST(cli, test_usage_list_delimiter) { + using Semicolon = rfl::cli::ListDelimiter<";">; + EXPECT_EQ((rfl::cli::usage("app", true).value()), + "Usage: app -r|--report= [--tags=] " + " ...\n" + "\n" + "Arguments:\n" + " -r, --report= Reports to write. Can be repeated. " + "Required.\n" + " --tags= Default: a;b. Can be repeated.\n" + " Required.\n" + " ... Files to process. Required.\n"); + const auto semicolon = + read({"-r", "a;b,c", "run", "x;y", "--tags=t;u"}); + ASSERT_TRUE(semicolon) << semicolon.error().what(); + EXPECT_EQ(semicolon.value().report.value().value(), + (Strings{"a", "b,c"})); + EXPECT_EQ(semicolon.value().tags.value(), (Strings{"t", "u"})); + EXPECT_EQ(semicolon.value().files.value().value(), (Strings{"x", "y"})); + + // Not split: every occurrence is one item, so a list takes one value per + // occurrence, and a default of several items, which no single value can + // spell, is left out. + using NoSplit = rfl::cli::ListDelimiter<"">; + EXPECT_EQ((rfl::cli::usage("app", true).value()), + "Usage: app -r|--report= [--tags=] " + " ...\n" + "\n" + "Arguments:\n" + " -r, --report= Reports to write. Can be repeated. " + "Required.\n" + " --tags= Can be repeated.\n" + " Required.\n" + " ... Files to process. Required.\n"); + const auto no_split = + read({"-r", "a,b", "-r", "c", "run", "x,y", "z"}); + ASSERT_TRUE(no_split) << no_split.error().what(); + EXPECT_EQ(no_split.value().report.value().value(), (Strings{"a,b", "c"})); + EXPECT_EQ(no_split.value().files.value().value(), (Strings{"x,y", "z"})); +} + } // namespace test_usage_options