Add support for dotnet help <verb>

This commit adds supports for getting more detailed help by using the
`dotnet help <verb>` syntax (e.g. `dotnet help build`). This change
opens up the URL that is specified for each verb in the default browser
on the user's machine, so internet access is required.
This commit is contained in:
blackdwarf 2017-02-17 09:00:25 -08:00 committed by Zlatko Knezevic
parent b42697ff09
commit 4aacb22993
9 changed files with 292 additions and 50 deletions

View file

@ -8,6 +8,7 @@ using Microsoft.Build.Construction;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using FluentAssertions;
using HelpActual = Microsoft.DotNet.Tools.Help;
namespace Microsoft.DotNet.Help.Tests
{
@ -65,5 +66,39 @@ Advanced Commands:
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.");
}
[WindowsOnlyFact]
public void WhenRunOnWindowsDotnetHelpCommandShouldContainProperProcessInformation()
{
var proc = HelpActual.HelpCommand.ConfigureProcess("https://aka.ms/dotnet-build");
Assert.Equal("cmd", proc.StartInfo.FileName);
Assert.Equal("/c start https://aka.ms/dotnet-build", proc.StartInfo.Arguments);
}
[LinuxOnlyFact]
public void WhenRunOnLinuxDotnetHelpCommandShouldContainProperProcessInformation()
{
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()
{
var proc = HelpActual.HelpCommand.ConfigureProcess("https://aka.ms/dotnet-build");
Assert.Equal("open", proc.StartInfo.FileName);
Assert.Equal("https://aka.ms/dotnet-build", proc.StartInfo.Arguments);
}
}
}