Skip to content

Show defaults in rfl::cli::usage - #35

Open
clockblocker wants to merge 1 commit into
wave-base-6from
cli-usage-defaults
Open

clockblocker wants to merge 1 commit into
wave-base-6from
cli-usage-defaults

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Extends rfl::cli::usage(..., /*detailed=*/true) to append Default: <value>. to rows that have a default via rfl::DefaultVal or rfl::DefaultIfMissing.

Example

struct Config {
  rfl::Description<"Listen port", rfl::DefaultVal<int>> port = 8080;
  rfl::DefaultVal<std::vector<std::string>> tags = std::vector<std::string>{"a", "b"};
  rfl::DefaultVal<std::string> prefix = std::string("");
};

// rfl::cli::usage<Config>("app", true).value():
// Arguments:
//   --port=<value>        Listen port. Default: 8080.
//   --tags=<v1,v2,...>    Default: a,b.
//   --prefix=<value>      Default: "".

Key details

  • Usage line and required/optional status are unchanged.
  • Only shown when T{} can be constructed (matching when read uses defaults); non-scalar defaults (null, objects, empty lists) are omitted.
  • Numbers are formatted with the classic locale. Validator constraints and deprecations are split into Show validator constraints and deprecations in rfl::cli::usage #39.
  • Docs updated in cli.md.

Open question: is Default: <value>. welcome in detailed usage, or should usage stay strictly to description, choices, and Required.?

AI-authored. Depends on: #23.

The detailed help of rfl::cli::usage now also lists the default of each
argument: of rfl::DefaultVal fields, or of every field with
rfl::DefaultIfMissing, when T{} can be built. The usage line does not
change.

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