Show valid values of an enum option in help (#53)

This commit is contained in:
Domn Werner
2020-05-08 02:40:23 -07:00
committed by GitHub
parent cbb72b16ae
commit 33ca4da260
4 changed files with 94 additions and 4 deletions

View File

@@ -238,6 +238,34 @@ namespace CliFx.Tests
_output.WriteLine(stdOutData);
}
[Fact]
public async Task Help_text_shows_usage_format_which_lists_all_valid_values_for_enum_options()
{
// Arrange
await using var stdOut = new MemoryStream();
var console = new VirtualConsole(output: stdOut);
var application = new CliApplicationBuilder()
.AddCommand(typeof(EnumOptionsCommand))
.UseConsole(console)
.Build();
// Act
await application.RunAsync(new[] { "cmd-with-enum-opts", "--help" });
var stdOutData = console.Output.Encoding.GetString(stdOut.ToArray()).TrimEnd();
// Assert
stdOutData.Should().ContainAll(
"Usage",
"cmd-with-enum-opts", "[options]",
"Options",
"* --value", "Enum option.", "Valid values: Value1, Value2, Value3.",
"--nullable-value", "Nullable enum option.", "Valid values: Value1, Value2, Value3."
);
_output.WriteLine(stdOutData);
}
[Fact]
public async Task Help_text_lists_environment_variable_names_for_options_that_have_them_defined()
{