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.Name = "dotnet build";
|
||||||
app.FullName = LocalizableStrings.AppFullName;
|
app.FullName = LocalizableStrings.AppFullName;
|
||||||
app.Description = LocalizableStrings.AppDescription;
|
app.Description = LocalizableStrings.AppDescription;
|
||||||
app.AllowArgumentSeparator = true;
|
|
||||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||||
|
app.HandleRemainingArguments = true;
|
||||||
app.HelpOption("-h|--help");
|
app.HelpOption("-h|--help");
|
||||||
|
|
||||||
CommandArgument projectArgument = app.Argument($"<{LocalizableStrings.ProjectArgumentValueName}>", LocalizableStrings.ProjectArgumentDescription);
|
CommandArgument projectArgument = app.Argument($"<{LocalizableStrings.ProjectArgumentValueName}>", LocalizableStrings.ProjectArgumentDescription);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Clean
|
||||||
Name = "dotnet clean",
|
Name = "dotnet clean",
|
||||||
FullName = LocalizableStrings.AppFullName,
|
FullName = LocalizableStrings.AppFullName,
|
||||||
Description = LocalizableStrings.AppDescription,
|
Description = LocalizableStrings.AppDescription,
|
||||||
AllowArgumentSeparator = true,
|
HandleRemainingArguments = true,
|
||||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||||
};
|
};
|
||||||
app.HelpOption("-h|--help");
|
app.HelpOption("-h|--help");
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
Name = "pack",
|
Name = "pack",
|
||||||
FullName = LocalizableStrings.AppFullName,
|
FullName = LocalizableStrings.AppFullName,
|
||||||
Description = LocalizableStrings.AppDescription,
|
Description = LocalizableStrings.AppDescription,
|
||||||
AllowArgumentSeparator = true,
|
HandleRemainingArguments = true,
|
||||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
app.Name = "dotnet publish";
|
app.Name = "dotnet publish";
|
||||||
app.FullName = LocalizableStrings.AppFullName;
|
app.FullName = LocalizableStrings.AppFullName;
|
||||||
app.Description = LocalizableStrings.AppDescription;
|
app.Description = LocalizableStrings.AppDescription;
|
||||||
app.AllowArgumentSeparator = true;
|
app.HandleRemainingArguments = true;
|
||||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
||||||
app.HelpOption("-h|--help");
|
app.HelpOption("-h|--help");
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
||||||
Name = "restore",
|
Name = "restore",
|
||||||
FullName = LocalizableStrings.AppFullName,
|
FullName = LocalizableStrings.AppFullName,
|
||||||
Description = LocalizableStrings.AppDescription,
|
Description = LocalizableStrings.AppDescription,
|
||||||
AllowArgumentSeparator = true,
|
HandleRemainingArguments = true,
|
||||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Run
|
||||||
app.Description = LocalizableStrings.AppDescription;
|
app.Description = LocalizableStrings.AppDescription;
|
||||||
app.HandleResponseFiles = true;
|
app.HandleResponseFiles = true;
|
||||||
app.AllowArgumentSeparator = true;
|
app.AllowArgumentSeparator = true;
|
||||||
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
app.ArgumentSeparatorHelpText = LocalizableStrings.RunCommandAdditionalArgsHelpText;
|
||||||
app.HelpOption("-h|--help");
|
app.HelpOption("-h|--help");
|
||||||
|
|
||||||
CommandOption configuration = app.Option(
|
CommandOption configuration = app.Option(
|
||||||
|
|
|
@ -21,11 +21,11 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
{
|
{
|
||||||
Name = "dotnet test",
|
Name = "dotnet test",
|
||||||
FullName = LocalizableStrings.AppFullName,
|
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");
|
cmd.HelpOption("-h|--help");
|
||||||
|
|
||||||
var argRoot = cmd.Argument(
|
var argRoot = cmd.Argument(
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
||||||
[InlineData("pack", true)]
|
[InlineData("pack", true)]
|
||||||
[InlineData("publish", true)]
|
[InlineData("publish", true)]
|
||||||
[InlineData("restore", 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)
|
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.";
|
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]
|
[Fact]
|
||||||
public void WhenTelemetryIsEnabledTheLoggerIsAddedToTheCommandLine()
|
public void WhenTelemetryIsEnabledTheLoggerIsAddedToTheCommandLine()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue