Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public static async Task<int> ExecuteAsync(
// Parse command
var parseResult = rootCommand.Parse(args);

// Short-circuit on parse errors: let InvokeAsync report them and return the
// corresponding exit code.
if (parseResult.Errors.Count > 0)
{
return await parseResult.InvokeAsync(invocationConfiguration, cancellationToken);
}

var format = parseResult.GetValue(Opt<OptionalOutputFormatOption>.Instance);

if (format.HasValue)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace ChilliCream.Nitro.CommandLine.Tests.Commands;

public sealed class GlobalOptionsCommandTests(NitroCommandFixture fixture) : CommandTestBase(fixture)
{
[Fact]
public async Task ExecuteAsync_InvalidOutputValue_ReturnsError()
{
// arrange
SetupNoAuthentication();

// act
var result = await ExecuteCommandAsync("api", "list", "--output", "wtf");

// assert
Assert.Equal(1, result.ExitCode);
result.StdErr.MatchInlineSnapshot(
"""
Argument 'wtf' not recognized. Must be one of:
'json'
""");
}
}
227 changes: 0 additions & 227 deletions src/Nitro/CommandLine/test/CommandLine.Tests/Commands/README.md

This file was deleted.

Loading
Loading