Replace dotnet help parser with CliCommandLineParser

CliCommandLineParserVersion 138 cannot use help as command and --help as
opinion at the same timem, update to 142
This commit is contained in:
William Li 2017-04-05 11:30:45 -07:00
parent cddffb08d2
commit a6d3012da1
9 changed files with 147 additions and 45 deletions

View file

@ -25,7 +25,7 @@ Arguments:
Common options:
-v|--verbose Enable verbose output
-h|--help Show help
-h|--help Show help
Host options (passed before the command):
-d|--diagnostics Enable diagnostic output
@ -67,12 +67,21 @@ Advanced Commands:
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
}
[Fact]
public void WhenHelpCommandIsPassedToDotnetItPrintsUsage()
{
var cmd = new HelpCommand()
.ExecuteWithCapturedOutput();
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
}
[Fact]
public void WhenInvalidCommandIsPassedToDotnetHelpItPrintsError()
{
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput("help invalid");
cmd.Should().Fail();
cmd.StdErr.Should().ContainVisuallySameFragment($"Specified command 'invalid' is not a valid CLI command. Please specify a valid CLI commands. For more information, run dotnet help.");
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
@ -92,7 +101,7 @@ Advanced Commands:
var proc = HelpActual.HelpCommand.ConfigureProcess("https://aka.ms/dotnet-build");
Assert.Equal("xdg-open", proc.StartInfo.FileName);
Assert.Equal("https://aka.ms/dotnet-build", proc.StartInfo.Arguments);
}
[MacOsOnlyFact]
public void WhenRunOnMacOsDotnetHelpCommandShouldContainProperProcessInformation()

View file

@ -0,0 +1,37 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using FluentAssertions;
using HelpActual = Microsoft.DotNet.Tools.Help;
namespace Microsoft.DotNet.Help.Tests
{
public class GivenThatIWantToShowHelpForDotnetHelpCommand : TestBase
{
private const string HelpText =
@".NET CLI help utility
Usage: dotnet help [options] <COMMAND_NAME>
Arguments:
<COMMAND_NAME> CLI command for which to view more detailed help.
Options:
-h, --help Show help information";
[Theory]
[InlineData("--help")]
[InlineData("-h")]
[InlineData("-?")]
[InlineData("/?")]
public void WhenHelpOptionIsPassedToDotnetHelpCommandItPrintsUsage(string helpArg)
{
var cmd = new HelpCommand()
.ExecuteWithCapturedOutput($"{helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
}
}
}