Skip to content

Refactor CLI to use System.CommandLine - #112

Merged
xping-admin merged 3 commits into
mainfrom
feature/migrate-cli-system-commandline
Aug 10, 2026
Merged

Refactor CLI to use System.CommandLine#112
xping-admin merged 3 commits into
mainfrom
feature/migrate-cli-system-commandline

Conversation

@xping-admin

Copy link
Copy Markdown
Collaborator

Migrate the command-line interface to utilize System.CommandLine for improved command handling and option parsing. Update error messages for consistency and clarity. Remove outdated option parsing classes.

@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Xping.Cli/Program.cs 97.70% 0 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
src/Xping.Cli/Commands/ReportOptions.cs 100.00% <100.00%> (+14.58%) ⬆️
src/Xping.Cli/Program.cs 97.08% <97.70%> (+0.15%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Xping.Cli command-line surface from custom argument parsing to System.CommandLine, aligning CLI behavior and diagnostics with the library’s built-in parsing/validation model and updating tests accordingly.

Changes:

  • Replaced manual verb/option parsing in src/Xping.Cli/Program.cs with a RootCommand + subcommands (report, where, clear, version) and System.CommandLine validators/parsers.
  • Updated CLI tests to assert on System.CommandLine’s standardized error/help text.
  • Removed legacy option parsing types (WhereOptions, ClearOptions) and converted ReportOptions to a simple mutable options bag.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Xping.Cli.Tests/ProgramTests.cs Updates expectations to match new help output and parse error wording.
tests/Xping.Cli.Tests/Commands/ReviewFixesTests.cs Updates assertions for missing-argument / unrecognized-token errors produced by System.CommandLine.
tests/Xping.Cli.Tests/Commands/ReportCommandTests.cs Updates assertions for unknown options and missing option values under the new parser.
src/Xping.Cli/Xping.Cli.csproj Adds System.CommandLine package reference required for the refactor.
src/Xping.Cli/Program.cs Implements the new command model, option definitions, validation, and invocation flow.
src/Xping.Cli/Commands/WhereOptions.cs Deletes obsolete manual parsing type.
src/Xping.Cli/Commands/ReportOptions.cs Removes parsing logic and makes properties settable for command binding.
src/Xping.Cli/Commands/ClearOptions.cs Deletes obsolete manual parsing type.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Xping.Cli/Program.cs Outdated
Comment thread src/Xping.Cli/Program.cs
Comment thread src/Xping.Cli/Program.cs
xping-admin and others added 2 commits August 9, 2026 22:57
…and help hint

CustomParser now indexes into Tokens defensively instead of calling
Single(), and parse-error hints point at the specific subcommand's
--help again instead of always suggesting the root help.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both now read AssemblyInformationalVersionAttribute directly, so the
`version` subcommand no longer diverges from System.CommandLine's
built-in --version option (previously 1.0.0.0 vs 1.0.0+<sha>).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (3)

src/Xping.Cli/Program.cs:146

  • Inside SetAction, option values are read via parseResult.GetValue(...), but in System.CommandLine 2.0 the supported API is GetValueForOption(...). Using GetValue here will fail to compile against the referenced package.
            var options = new ReportOptions
            {
                Last = parseResult.GetValue(lastOption),
                Assembly = parseResult.GetValue(assemblyOption),
                Directory = parseResult.GetValue(directoryOption),

src/Xping.Cli/Program.cs:203

  • clear command handler reads option values via parseResult.GetValue(...), but System.CommandLine 2.0 uses GetValueForOption(...). As written this will not compile against the referenced package version.
        command.SetAction(parseResult => ClearCommand.Run(
            parseResult.GetValue(directoryOption),
            parseResult.GetValue(assemblyOption),
            parseResult.GetValue(forceOption),
            input,

src/Xping.Cli/Program.cs:169

  • where command handler reads the option value via parseResult.GetValue(...), but System.CommandLine 2.0 uses GetValueForOption(...). This should be updated to match the referenced API.
        Command command = new("where", "Show where local runs are stored") { directoryOption };

        command.SetAction(parseResult => WhereCommand.Run(parseResult.GetValue(directoryOption), output));

Comment thread src/Xping.Cli/Program.cs
@xping-admin
xping-admin merged commit ce1fea3 into main Aug 10, 2026
3 checks passed
@xping-admin
xping-admin deleted the feature/migrate-cli-system-commandline branch August 10, 2026 07:57
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.

2 participants