Skip to content

Accept repeated list options in rfl::cli - #26

Open
clockblocker wants to merge 1 commit into
wave-base-7from
cli-repeated-lists
Open

clockblocker wants to merge 1 commit into
wave-base-7from
cli-repeated-lists

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Allows list options in rfl::cli::read to be repeated across multiple flags (--report=a --report=b), appending items in argv order instead of failing with Duplicate argument. Purely additive.

Example

struct Config {
  rfl::Short<"r", std::vector<std::string>> report;
  std::optional<std::string> output;
};

// Before: error — Duplicate argument: --report=b
// After:  report = {"a", "b", "c", "d"}
rfl::cli::read<Config>({"-r", "a", "--report=b,c", "-r", "d"});

// Scalars still fail:
// --output=a --output=b -> Duplicate argument: --output=b

Key details

  • Works for vectors, sets, std::array, tuples, pairs, nested lists (--database.replicas), map-value lists, and wrapped fields; empty occurrences (--report=) add nothing.
  • Later occurrences are stored separately rather than comma-joined, so values aren't re-split.
  • rfl::cli::usage appends Can be repeated. to list option rows.
  • Public resolve_args<T, Ps> keeps its signature and flat-map return type (rejecting repeated options as before).
  • Docs updated in cli.md ("Lists and repeated options").

AI-authored. Depends on: #24, #25, #35, #39.

@clockblocker clockblocker changed the title Accept repeated list options, and let a list as the last positional field take the remaining arguments Accept repeated list options in rfl::cli Nov 14, 2026
@clockblocker
clockblocker changed the base branch from wave-base-5 to wave-base-7 November 14, 2026 13:01
@clockblocker
clockblocker force-pushed the cli-repeated-lists branch 2 times, most recently from f296f14 to 23e703b Compare November 16, 2026 05:18
@clockblocker
clockblocker force-pushed the wave-base-7 branch 2 times, most recently from ce84e34 to 37ee897 Compare November 17, 2026 05:11
@clockblocker
clockblocker force-pushed the cli-repeated-lists branch 2 times, most recently from 03b1be2 to 713631b Compare November 17, 2026 07:15
@clockblocker
clockblocker force-pushed the wave-base-7 branch 2 times, most recently from 385e359 to 417c86b Compare November 17, 2026 09:34
A list field (vector, set, std::array, tuple, pair, ... through any
wrapper) now takes every occurrence of its option, long or short: each
occurrence is split at the commas and the items are added in argv order,
so `--report=a,b --report=c` gives [a, b, c]. Any other option still
fails when repeated, with the same messages.

The option table marks list options (Option::is_list). parse_argv keeps
a list's first occurrence in `named` under its long name and the later
ones in ParsedArgs::later_occurrences; the overload of resolve_args that
takes the table returns them beside the flat map (internal::ResolvedArgs),
and the Reader adds their items. The public resolve_args<T> keeps its
flat-map result. Without rfl::NoExtraFields the table lists only the
top-level fields, so parse_argv looks up nested options in the table of
all paths, built the first time one is given.

usage marks list options "Can be repeated.".

Only inputs that used to fail change meaning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant