Skip to content

feat(cli): added support to configure exit code documentation - #85

Open
milkyware wants to merge 7 commits into
spectreconsole:mainfrom
milkyware:feat/exit-code-configurator
Open

milkyware wants to merge 7 commits into
spectreconsole:mainfrom
milkyware:feat/exit-code-configurator

Conversation

@milkyware

Copy link
Copy Markdown

Fixes #56

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

AI Declaration

  • OpenCode - Deepseek v4.1 Flash - Primarily for planning and implementation

Changes

  • Adds help-only support for documenting exit codes, modelled on the existing example handling
    • .AddExitCode() on IConfigurator for global exit codes
    • .WithExitCode() on ICommandConfigurator for command-specific exit codes
    • .WithExitCode() on DefaultCommandConfigurator and CommandApp<T> for default commands
    • Aggregates global and command/default exit codes in help output
    • Command/default descriptions override global descriptions for duplicate codes
    • Renders a sorted, styled EXIT CODES section; omitted when no codes are configured
  • Exit codes are documentation only
    • Does not validate runtime return values
    • Does not constrain codes to a numeric range
    • Does not enforce uniqueness across different commands
  • Adds configuration validation
    • Rejects duplicate global, command, and default-command codes
    • Rejects null or whitespace descriptions with CommandConfigurationException
    • Trims descriptions before storing them
  • Adds EXIT CODES resource entries across the existing help resource files
    • Non-English strings are Google Translate output and should be reviewed before release
  • Adds unit and snapshot coverage
    • Root help, command help, default-command help, CommandApp<T>, branches, and override behaviour
    • Duplicate registration, missing descriptions, and trimming
    • Exact-line assertions catch leading and trailing whitespace
  • Adds .ReplaceLineEndings() in the pair deconstructor test
    • Isolated in its own commit as a cross-platform test fix
  • Scope and compatibility notes
    • Help output only; XML, OpenCLI, and cli explain are unchanged
    • New members on public interfaces are breaking for third-party implementations, accepted under 0.x
    • Branch default commands cannot register exit codes because SetDefaultCommand returns void

Please upvote 👍 this pull request if you are interested in it.

@milkyware

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

Specify exit codes in the --help text

1 participant