Skip to content

[Nitro CLI] Properly handle invalid --output option value#9576

Merged
tobias-tengler merged 1 commit intomainfrom
tte/properly-handle-invalid-output-option
Apr 17, 2026
Merged

[Nitro CLI] Properly handle invalid --output option value#9576
tobias-tengler merged 1 commit intomainfrom
tte/properly-handle-invalid-output-option

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 17, 2026 17:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates Nitro CLI command execution to properly handle command-line parse errors (specifically invalid --output values) by short-circuiting execution before session/client initialization, and adds/adjusts tests to cover the behavior.

Changes:

  • Short-circuit NitroRootCommand.ExecuteAsync(...) on parse errors and delegate to ParseResult.InvokeAsync(...) for correct error reporting/exit codes.
  • Add a command-level test verifying invalid --output values return an error and the expected parse error output.
  • Consolidate/extend environment-variable default option testing and introduce shared test utilities (fixture, interaction mode enum, error factory).

Reviewed changes

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

Show a summary per file
File Description
src/Nitro/CommandLine/src/CommandLine/Extensions/RootCommandExtensions.cs Avoids accessing parsed option values when parsing failed; relies on System.CommandLine’s error reporting.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/GlobalOptionsCommandTests.cs Adds regression test for invalid --output value handling.
src/Nitro/CommandLine/test/CommandLine.Tests/GlobalOptionsTests.cs Moves/extends env var default tests and refactors the test harness to support env provider injection/probe command configuration.
src/Nitro/CommandLine/test/CommandLine.Tests/Options/EnvironmentVariableDefaultTests.cs Removes now-redundant standalone env var default test file.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/NitroCommandFixture.cs Introduces shared root-command fixture for command tests.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/InteractionMode.cs Adds interaction mode enum used across command tests.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/MockErrorFactory.cs Adds centralized mock error setup helpers used by multiple command test bases.
src/Nitro/CommandLine/test/CommandLine.Tests/Commands/README.md Removes the command test migration guide document.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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