From 5558e5f7287c03bc169f807671cf0f04ed696f62 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 15 Dec 2016 15:13:00 -0800 Subject: [PATCH 1/3] Changing the host verbosity flag to -d|--diagnostics from -v|--verbosity so that it is not confused with the verbs verbosity flag. --- src/dotnet/Program.cs | 2 +- src/dotnet/commands/dotnet-help/HelpCommand.cs | 2 +- src/dotnet/commands/dotnet-help/LocalizableStrings.cs | 2 ++ test/EndToEnd/GivenDotNetUsesMSBuild.cs | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index 4d8786ccf..28ba9f75e 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -116,7 +116,7 @@ namespace Microsoft.DotNet.Cli { for (; lastArg < args.Length; lastArg++) { - if (IsArg(args[lastArg], "v", "verbose")) + if (IsArg(args[lastArg], "d", "diagnostics")) { verbose = true; } diff --git a/src/dotnet/commands/dotnet-help/HelpCommand.cs b/src/dotnet/commands/dotnet-help/HelpCommand.cs index 416f85019..1b442211c 100644 --- a/src/dotnet/commands/dotnet-help/HelpCommand.cs +++ b/src/dotnet/commands/dotnet-help/HelpCommand.cs @@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tools.Help -h|--help {LocalizableStrings.HelpDefinition} {LocalizableStrings.HostOptions}: - -v|--verbose {LocalizableStrings.VerboseDefinition} + -d|--diagnostics {LocalizableStrings.DiagnosticsDefinition} --version {LocalizableStrings.VersionDescription} --info {LocalizableStrings.InfoDescription} diff --git a/src/dotnet/commands/dotnet-help/LocalizableStrings.cs b/src/dotnet/commands/dotnet-help/LocalizableStrings.cs index 952d5bf1d..bbd1e5e42 100644 --- a/src/dotnet/commands/dotnet-help/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-help/LocalizableStrings.cs @@ -18,6 +18,8 @@ public const string VerboseDefinition = "Enable verbose output"; + public const string DiagnosticsDefinition = "Enable diagnostics output"; + public const string HelpDefinition = "Show help"; public const string HostOptions = "Host options (passed before the command)"; diff --git a/test/EndToEnd/GivenDotNetUsesMSBuild.cs b/test/EndToEnd/GivenDotNetUsesMSBuild.cs index b38396287..aa1c84896 100644 --- a/test/EndToEnd/GivenDotNetUsesMSBuild.cs +++ b/test/EndToEnd/GivenDotNetUsesMSBuild.cs @@ -109,7 +109,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd new DotnetCommand() .WithWorkingDirectory(testProjectDirectory) .ExecuteWithCapturedOutput( - $"-v dependency-tool-invoker -c {configuration} -f netcoreapp1.0 portable") + $"-d dependency-tool-invoker -c {configuration} -f netcoreapp1.0 portable") .Should().Pass() .And.HaveStdOutContaining("Hello Portable World!");; } From 9fd4903bf38349226853b8ea1a73a256e1368f12 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 15 Dec 2016 16:55:52 -0800 Subject: [PATCH 2/3] Addressing code review comments and adding a test for dotnet --help. --- .../dotnet-help/LocalizableStrings.cs | 2 +- ...ivenThatIWantToShowHelpForDotnetCommand.cs | 64 +++++++++++++++++++ .../dotnet-help.Tests.csproj | 63 ++++++++++++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs create mode 100644 test/dotnet-help.Tests/dotnet-help.Tests.csproj diff --git a/src/dotnet/commands/dotnet-help/LocalizableStrings.cs b/src/dotnet/commands/dotnet-help/LocalizableStrings.cs index bbd1e5e42..4cd4d3022 100644 --- a/src/dotnet/commands/dotnet-help/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-help/LocalizableStrings.cs @@ -18,7 +18,7 @@ public const string VerboseDefinition = "Enable verbose output"; - public const string DiagnosticsDefinition = "Enable diagnostics output"; + public const string DiagnosticsDefinition = "Enable diagnostic output"; public const string HelpDefinition = "Show help"; diff --git a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs new file mode 100644 index 000000000..620a257c6 --- /dev/null +++ b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs @@ -0,0 +1,64 @@ +// 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 System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Build.Construction; +using Microsoft.DotNet.Tools.Test.Utilities; +using Xunit; +using FluentAssertions; + +namespace Microsoft.DotNet.Help.Tests +{ + public class GivenThatIWantToShowHelpForDotnetCommand : TestBase + { + private const string HelpText = +@"Usage: dotnet [host-options] [command] [arguments] [common-options] + +Arguments: + [command] The command to execute + [arguments] Arguments to pass to the command + [host-options] Options specific to dotnet (host) + [common-options] Options common to all commands + +Common options: + -v|--verbose Enable verbose output + -h|--help Show help + +Host options (passed before the command): + -d|--diagnostic Enable diagnostics output + --version Display .NET CLI Version Number + --info Display .NET CLI Info + +Commands: + new Initialize a basic .NET project + restore Restore dependencies specified in the .NET project + build Builds a .NET project + publish Publishes a .NET project for deployment (including the runtime) + run Compiles and immediately executes a .NET project + test Runs unit tests using the test runner specified in the project + pack Creates a NuGet package + migrate Migrates a project.json based project to a msbuild based project + +Project modification commands: + add Add items to the project + remove Remove items from the project + list List items in the project + +Advanced Commands: + nuget Provides additional NuGet commands + msbuild msbuilds a project and all of its dependencies + vstest Runs tests from the specified files"; + + [Theory] + [InlineData("--help")] + [InlineData("-h")] + public void WhenHelpOptionIsPassedToDotnetItPrintsUsage(string helpArg) + { + var cmd = new DotnetCommand() + .ExecuteWithCapturedOutput($"{helpArg}"); + cmd.Should().Pass().And.HaveStdOutContaining(HelpText); + } + } +} diff --git a/test/dotnet-help.Tests/dotnet-help.Tests.csproj b/test/dotnet-help.Tests/dotnet-help.Tests.csproj new file mode 100644 index 000000000..7dc1ad5c9 --- /dev/null +++ b/test/dotnet-help.Tests/dotnet-help.Tests.csproj @@ -0,0 +1,63 @@ + + + + + + netcoreapp1.0 + true + dotnet-help.Tests + $(PackageTargetFallback);dnxcore50;portable-net45+win8 + + + + + + + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + $(CLI_NETSDK_Version) + All + + + 15.0.0-preview-20161024-02 + + + 2.2.0-beta4-build1194 + + + 1.0.1 + + + $(CLI_MSBuild_Version) + + + 2.2.0-beta4-build3444 + + + + + From 2336cd7aa0721c53e34d8bb543bc18d7f66676e7 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Fri, 16 Dec 2016 12:35:25 -0800 Subject: [PATCH 3/3] Fixing the help message. --- .../GivenThatIWantToShowHelpForDotnetCommand.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs index 620a257c6..7fc6cf508 100644 --- a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs +++ b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs @@ -24,10 +24,10 @@ Arguments: Common options: -v|--verbose Enable verbose output - -h|--help Show help + -h|--help Show help Host options (passed before the command): - -d|--diagnostic Enable diagnostics output + -d|--diagnostics Enable diagnostic output --version Display .NET CLI Version Number --info Display .NET CLI Info