Skip to content

Accept grouped short options such as -qfcsv in rfl::cli - #24

Closed
clockblocker wants to merge 1 commit into
wave-base-5from
cli-grouped-short-options
Closed

clockblocker wants to merge 1 commit into
wave-base-5from
cli-grouped-short-options

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds POSIX-style grouped short options (such as -qv, -fcsv, -qf csv) to rfl::cli::read. Purely additive — no input that parses on main changes meaning.

Example

struct Config {
  rfl::Short<"q", rfl::DefaultVal<bool>> quiet = false;
  rfl::Short<"v", rfl::DefaultVal<bool>> verbose = false;
  rfl::Short<"f", std::optional<std::string>> format;
  rfl::Short<"p", std::optional<int>> priority;
};
Input Result
-qv quiet=true, verbose=true
-fcsv / -qfcsv / -qf csv format="csv" (and quiet=true)
-qv false quiet=true, verbose=false
-p-42 / -p -42 priority=-42 (-42 alone stays positional)
-vq=false Option '-q' does not take a value in '-vq=false'. Write '-q=false' on its own.
-qxf Unknown short argument: -x (in '-qxf').

Key details

  • Flags consume one character each; the first value-taking option takes the rest of the token (or the next token if at the end of the group).
  • Negative numbers remain positional unless a digit short option (e.g. rfl::Short<"1", ...>) is declared.
  • Public table-less parse_argv(argc, argv) is unchanged.
  • Docs updated in cli.md ("Grouped short options").

Open question: -f=csv and -qf=csv parse as "csv" (matching main's -f=csv), whereas getopt gives "=csv". Keep main's behavior or match getopt?

AI-authored. Depends on: #22 (applied on #33, #34).

@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from e312ebc to 9d40965 Compare November 14, 2026 13:01
@clockblocker
clockblocker changed the base branch from wave-base-4 to wave-base-5 November 14, 2026 13:01
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 9d40965 to 437b2b3 Compare November 16, 2026 05:18
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 437b2b3 to 03d43d7 Compare November 17, 2026 04:18
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 03d43d7 to 3e781ce Compare November 17, 2026 05:11
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 3e781ce to 5ddbb41 Compare November 17, 2026 07:15
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 5ddbb41 to 2f8bb60 Compare November 17, 2026 09:25
rfl::cli::read now accepts several short options in one token: in
`-qvf` every flag is set up to the first option that takes a value,
which takes the rest of the token (`-qfcsv`) or, if nothing is left,
the next token (`-qf csv`). `-f=csv` keeps meaning "csv". A flag inside a
group takes no value, and an unknown letter fails with
"Unknown short argument: -x (in '-qxf').".

Inputs that parsed before keep their meaning. Grouping needs the option
table, so the public parse_argv still reads `-abc` as the short option
"abc".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clockblocker
clockblocker force-pushed the cli-grouped-short-options branch from 2f8bb60 to f940fb7 Compare November 25, 2026 12:08
@clockblocker

Copy link
Copy Markdown
Owner Author

Merged upstream as munich-data-engineering#798; closing fork PR (branch preserved).

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