Skip to content

Show validator constraints and deprecations in rfl::cli::usage - #39

Open
clockblocker wants to merge 1 commit into
cli-usage-defaultsfrom
cli-usage-constraints
Open

clockblocker wants to merge 1 commit into
cli-usage-defaultsfrom
cli-usage-constraints

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Split from #35: extends rfl::cli::usage(..., /*detailed=*/true) to show rfl::Validator constraints and rfl::Deprecated notices on each option row.

Example

struct Config {
  rfl::Validator<int, rfl::Minimum<1>, rfl::Maximum<65535>> port;
  rfl::Validator<std::vector<std::string>, rfl::Size<rfl::Minimum<1>, rfl::Maximum<3>>> tags;
  rfl::Validator<std::string, rfl::Pattern<"^[a-z]+$">> name;
  rfl::Deprecated<"Use --output", "Legacy path", std::optional<std::string>> out;
};

// Detailed rows include:
//   --port=<value>        Range: 1..65535. Required.
//   --tags=<v1,v2,...>    Size: 1..3. Required.
//   --name=<value>        Pattern: ^[a-z]+$. Required.
//   --out=<value>         Legacy path. Deprecated: Use --output.

Key details

  • Reads directly from schema Validated and Deprecated nodes, matching rfl::json::to_schema.
  • Supports numeric bounds (Range: 1..65535., > 0 and <= 1, <= 0 or >= 10, != 0), container/string sizes (Size: >= 1., 1..3), regex patterns (Pattern: ...), and Deprecated: <message>. (or Deprecated. if empty). Other custom validators are omitted.
  • Usage line and required/optional status are unchanged. Docs updated in cli.md.

Open question: is this extra constraint/deprecation text welcome in detailed usage?

AI-authored. Depends on: #35.

The detailed help of rfl::cli::usage now also lists, per argument, the
constraints of its validators (`Range: 1..65535.`, `Size: >= 1.`,
`Pattern: ^[a-z]+$.`) and `Deprecated: <message>.` for rfl::Deprecated.
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