Remove argument separator from commands (#5080)
* Remove argument separator from commands Currently, the argument separator (`--`) is only supported on `dotnet run`. This PR removes it from other commands to make the help and usage of these command clearer. * Adding dotnet run message test * Responding to PR feedback
This commit is contained in:
parent
2d5e40f3ba
commit
b467d66182
8 changed files with 23 additions and 10 deletions
|
@ -18,8 +18,8 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
app.Name = "dotnet build";
|
||||
app.FullName = LocalizableStrings.AppFullName;
|
||||
app.Description = LocalizableStrings.AppDescription;
|
||||
app.AllowArgumentSeparator = true;
|
||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||
app.HandleRemainingArguments = true;
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
CommandArgument projectArgument = app.Argument($"<{LocalizableStrings.ProjectArgumentValueName}>", LocalizableStrings.ProjectArgumentDescription);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Clean
|
|||
Name = "dotnet clean",
|
||||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
AllowArgumentSeparator = true,
|
||||
HandleRemainingArguments = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
};
|
||||
app.HelpOption("-h|--help");
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
Name = "pack",
|
||||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
AllowArgumentSeparator = true,
|
||||
HandleRemainingArguments = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
app.Name = "dotnet publish";
|
||||
app.FullName = LocalizableStrings.AppFullName;
|
||||
app.Description = LocalizableStrings.AppDescription;
|
||||
app.AllowArgumentSeparator = true;
|
||||
app.HandleRemainingArguments = true;
|
||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
Name = "restore",
|
||||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
AllowArgumentSeparator = true,
|
||||
HandleRemainingArguments = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
app.Description = LocalizableStrings.AppDescription;
|
||||
app.HandleResponseFiles = true;
|
||||
app.AllowArgumentSeparator = true;
|
||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||
app.ArgumentSeparatorHelpText = LocalizableStrings.RunCommandAdditionalArgsHelpText;
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
CommandOption configuration = app.Option(
|
||||
|
|
|
@ -21,11 +21,11 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
{
|
||||
Name = "dotnet test",
|
||||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
HandleRemainingArguments = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
};
|
||||
|
||||
cmd.AllowArgumentSeparator = true;
|
||||
cmd.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||
cmd.HelpOption("-h|--help");
|
||||
|
||||
var argRoot = cmd.Argument(
|
||||
|
|
|
@ -56,7 +56,6 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
[InlineData("pack", true)]
|
||||
[InlineData("publish", true)]
|
||||
[InlineData("restore", true)]
|
||||
[InlineData("run", true)]
|
||||
public void When_help_is_invoked_Then_MSBuild_extra_options_text_is_included_in_output(string commandName, bool isMSBuildCommand)
|
||||
{
|
||||
const string MSBuildHelpText = " Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options.";
|
||||
|
@ -77,6 +76,20 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenDotnetRunHelpIsInvokedAppArgumentsTextIsIncludedInOutput()
|
||||
{
|
||||
const string AppArgumentsText = "Arguments passed to the application that is being run.";
|
||||
|
||||
var projectDirectory = TestAssetsManager.CreateTestDirectory("RunContainsAppArgumentsText");
|
||||
var result = new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(projectDirectory.Path)
|
||||
.ExecuteWithCapturedOutput("run --help");
|
||||
|
||||
result.ExitCode.Should().Be(0);
|
||||
result.StdOut.Should().Contain(AppArgumentsText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenTelemetryIsEnabledTheLoggerIsAddedToTheCommandLine()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue