Skip to content

Commit

Permalink
built-in option improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
orakist committed Jan 26, 2024
1 parent 809c4f8 commit 3db6852
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ These are command line options of this application.
Usage: [-n (value)] [-c <value>]
```

To print hidden options too, set verbosity level to detailed or trace. See the following output --verbosity is a hidden option. For example:
To print hidden options too, set verbosity level to detailed or trace. See the following help output with hidden options:

```console
./> --help --vl:detailed
Expand Down
2 changes: 2 additions & 0 deletions src/Oaksoft.ArgumentParser/Builder/ArgumentParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private void BuildVersionOption()
option.SetName(nameof(IBuiltInOptions.Version), false);
option.SetValidAliases(validAliases);
option.SetDescription("Shows version-number of the application.");
((BaseValueOption)option).SetValueArity(ArityType.Zero);
}

private void BuildHelpOption()
Expand All @@ -211,6 +212,7 @@ private void BuildHelpOption()
option.SetName(nameof(IBuiltInOptions.Help), false);
option.SetValidAliases(validAliases);
option.SetDescription("Shows help and usage information.");
((BaseValueOption)option).SetValueArity(ArityType.Zero);
}

private void BuildVerbosityOption()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ public void ShouldParseHelp_WhenHelpInputIsTrue()
parser.IsHelpOption.ShouldBeTrue();
}

[Fact]
public void ShouldParseHelp_WhenHelpInputIsFalse()
{
// Arrange
var sut = CommandLine.CreateParser<SampleOptionNames>()
.AddNamedOption(s => s.Value);

// Act & Assert
var parser = sut.Build();
parser.Parse("-h:false");

var builtInOpts = parser.GetBuiltInOptions();
builtInOpts.Help.ShouldBe(false);
parser.IsHelpOption.ShouldBeFalse();
}

[Fact]
public void ShouldCreateError_WhenHelpInputIsNotValid()
{
Expand Down

0 comments on commit 3db6852

Please sign in to comment.