Skip to content

feat(commandline): fluent Command builder, env var fallback, and help section grouping#33

Merged
deer merged 2 commits intomainfrom
commandline
Apr 8, 2026
Merged

feat(commandline): fluent Command builder, env var fallback, and help section grouping#33
deer merged 2 commits intomainfrom
commandline

Conversation

@deer
Copy link
Copy Markdown
Collaborator

@deer deer commented Apr 8, 2026

New: Command fluent builder

  • Command.create("spin").option(...).section(...).envVar(...).build()
  • Deferred registration — all add() calls applied at build() time
  • NoSuchMethodException wrapped as IllegalArgumentException

New: env var fallback on CommandLineParser

  • registerEnvVar(String envVarName, String prefix) maps an env var to a CLI prefix
  • setEnvironmentVariableResolver(Function) for custom resolution (defaults to System::getenv, pass null to disable)
  • Env var args are prepended so command-line arguments always take precedence

New: help section grouping on CommandLineParser

  • setHelpSection(String name) / Command.section(String name) group options under named headings
  • Mirrors cliffy's .group() API — registration-order-based, not annotation-based
  • Purely a rendering concern; parse behaviour is unaffected

Tests

  • Split CommandLineParserTests into four focused files: CommandLineParserTests, CommandTests, CommandLineParserSectionTests, CommandLineParserEnvVarTests

@deer deer merged commit a424145 into main Apr 8, 2026
3 checks passed
@deer deer deleted the commandline branch April 8, 2026 12:59
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