mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-22 09:35:48 +08:00
Make -v|--version opt-in
We added an automatic version option in 0.49. We did this with good intentions, but forgot that people might already use --version as an option for a root command. This commit makes -v|--version completely opt-in.
This commit is contained in:
committed by
Patrik Svensson
parent
88515b7d7f
commit
3acc90e47c
@@ -950,6 +950,45 @@ public sealed partial class CommandAppTests
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("NoVersion")]
|
||||
public Task Should_Not_Include_Application_Version_If_Not_Set()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.SetDefaultCommand<GenericCommand<ArgumentOrderSettings>>();
|
||||
fixture.Configure(config =>
|
||||
{
|
||||
config.SetApplicationName("myapp");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Version")]
|
||||
public Task Should_Include_Application_Version_If_Set()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.SetDefaultCommand<GenericCommand<ArgumentOrderSettings>>();
|
||||
fixture.Configure(config =>
|
||||
{
|
||||
config.SetApplicationName("myapp");
|
||||
config.SetApplicationVersion("0.49.1");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Hidden_Command_Options")]
|
||||
public Task Should_Not_Show_Hidden_Command_Options()
|
||||
|
||||
@@ -34,6 +34,24 @@ public sealed partial class CommandAppTests
|
||||
result.Output.ShouldBe("1.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Not_Display_Version_If_Not_Specified()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.AddCommand<EmptyCommand>("empty");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--version");
|
||||
|
||||
// Then
|
||||
result.ExitCode.ShouldNotBe(0);
|
||||
result.Output.ShouldStartWith("Error: Unexpected option 'version'");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Execute_Command_Not_Output_Application_Version_To_The_Console()
|
||||
{
|
||||
@@ -42,7 +60,6 @@ public sealed partial class CommandAppTests
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationVersion("1.0");
|
||||
|
||||
configurator.AddCommand<EmptyCommand>("empty");
|
||||
});
|
||||
|
||||
@@ -81,7 +98,6 @@ public sealed partial class CommandAppTests
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationVersion("1.0");
|
||||
|
||||
configurator.AddBranch<EmptyCommandSettings>("branch", branch =>
|
||||
{
|
||||
branch.SetDefaultCommand<EmptyCommand>();
|
||||
|
||||
Reference in New Issue
Block a user