mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-03 02:17:59 +08:00
Update help output for required options
This commit is contained in:

committed by
Patrik Svensson

parent
67c3909bbb
commit
e4b5b56d93
@ -1,6 +1,13 @@
|
||||
namespace Spectre.Console.Tests.Data;
|
||||
|
||||
public class RequiredOptionsSettings : CommandSettings
|
||||
{
|
||||
[CommandOption("--foo <VALUE>", true)]
|
||||
[Description("Foos the bars")]
|
||||
public string Foo { get; set; }
|
||||
}
|
||||
|
||||
public class RequiredOptionsWithoutDescriptionSettings : CommandSettings
|
||||
{
|
||||
[CommandOption("--foo <VALUE>", true)]
|
||||
public string Foo { get; set; }
|
||||
|
@ -0,0 +1,6 @@
|
||||
USAGE:
|
||||
myapp [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
--foo <VALUE> Foos the bars. Required
|
@ -0,0 +1,6 @@
|
||||
USAGE:
|
||||
myapp [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
--foo <VALUE> Foos the bars. Required
|
@ -0,0 +1,6 @@
|
||||
USAGE:
|
||||
myapp [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
--foo <VALUE> Required
|
@ -0,0 +1,6 @@
|
||||
USAGE:
|
||||
myapp [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
--foo <VALUE> Required
|
@ -1061,5 +1061,43 @@ public sealed partial class CommandAppTests
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Required_Options")]
|
||||
public Task Should_Show_Required_Options()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.SetDefaultCommand<GenericCommand<RequiredOptionsSettings>>();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Required_Options_No_Description")]
|
||||
public Task Should_Show_Required_Options_Without_Description()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.SetDefaultCommand<GenericCommand<RequiredOptionsWithoutDescriptionSettings>>();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace Spectre.Console.Cli.Tests.Unit.Testing;
|
||||
namespace Spectre.Console.Tests.Unit.Cli;
|
||||
|
||||
public sealed class InteractiveCommandTests
|
||||
{
|
||||
|
Reference in New Issue
Block a user