Squash
This commit is contained in:
parent
29b824a6ff
commit
82ec742d37
4 changed files with 59 additions and 24 deletions
25
src/dotnet/commands/dotnet-add/LocalizableStrings.cs
Normal file
25
src/dotnet/commands/dotnet-add/LocalizableStrings.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
namespace Microsoft.DotNet.Tools.Add
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string NetAddCommand = ".NET Add Command";
|
||||
|
||||
public const string Usage = "Usage";
|
||||
|
||||
public const string Options = "Options";
|
||||
|
||||
public const string HelpDefinition = "Show help information";
|
||||
|
||||
public const string Arguments = "Arguments";
|
||||
|
||||
public const string ArgumentsObjectDefinition = "The object of the operation. If a project file is not specified, it defaults to the current directory.";
|
||||
|
||||
public const string ArgumentsCommandDefinition = "Command to be executed on <object>.";
|
||||
|
||||
public const string ArgsDefinition = "Any extra arguments passed to the command. Use `dotnet add <command> --help` to get help about these arguments.";
|
||||
|
||||
public const string Commands = "Commands";
|
||||
|
||||
public const string CommandP2PDefinition = "Add project to project (p2p) reference to a project";
|
||||
}
|
||||
}
|
|
@ -16,22 +16,22 @@ namespace Microsoft.DotNet.Tools.Add
|
|||
{
|
||||
public class AddCommand : DispatchCommand
|
||||
{
|
||||
protected override string HelpText => @".NET Add Command
|
||||
protected override string HelpText => $@"{LocalizableStrings.NetAddCommand}
|
||||
|
||||
Usage: dotnet add [options] <object> <command> [[--] <arg>...]]
|
||||
{LocalizableStrings.Usage}: dotnet add [options] <object> <command> [[--] <arg>...]]
|
||||
|
||||
Options:
|
||||
-h|--help Show help information
|
||||
{LocalizableStrings.Options}:
|
||||
-h|--help {LocalizableStrings.HelpDefinition}
|
||||
|
||||
Arguments:
|
||||
<object> The object of the operation. If a project file is not specified, it defaults to the current directory.
|
||||
<command> Command to be executed on <object>.
|
||||
{LocalizableStrings.Arguments}:
|
||||
<object> {LocalizableStrings.ArgumentsObjectDefinition}
|
||||
<command> {LocalizableStrings.ArgumentsCommandDefinition}
|
||||
|
||||
Args:
|
||||
Any extra arguments passed to the command. Use `dotnet add <command> --help` to get help about these arguments.
|
||||
{LocalizableStrings.ArgsDefinition}
|
||||
|
||||
Commands:
|
||||
p2p Add project to project (p2p) reference to a project";
|
||||
{LocalizableStrings.Commands}:
|
||||
p2p {LocalizableStrings.CommandP2PDefinition}";
|
||||
|
||||
protected override Dictionary<string, Func<string[], int>> BuiltInCommands => new Dictionary<string, Func<string[], int>>
|
||||
{
|
||||
|
|
|
@ -2,10 +2,22 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
|||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string ReferenceIsInvalid = "Reference `{0}` is invalid.";
|
||||
public const string AppFullName = ".NET Add Project to Project (p2p) reference Command";
|
||||
|
||||
public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add. Please run dotnet add --help for more information.";
|
||||
public const string AppDescription = "Command to add project to project (p2p) reference";
|
||||
|
||||
public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`.";
|
||||
public const string AppHelpText = "Project to project references to add";
|
||||
|
||||
public const string CmdProject = "PROJECT";
|
||||
|
||||
public const string CmdProjectDescription = "The project file to modify. If a project file is not specified, it searches the current working directory for an MSBuild file that has a file extension that ends in `proj` and uses that file.";
|
||||
|
||||
public const string CmdFramework = "FRAMEWORK";
|
||||
|
||||
public const string CmdFrameworkDescription = "Add reference only when targetting a specific framework";
|
||||
|
||||
public const string CmdForceDescription = "Add reference even if it does not exist, do not convert paths to relative";
|
||||
|
||||
public const string ProjectException = "Project";
|
||||
}
|
||||
}
|
|
@ -16,34 +16,32 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
|||
CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false)
|
||||
{
|
||||
Name = "dotnet add p2p",
|
||||
FullName = ".NET Add Project to Project (p2p) reference Command",
|
||||
Description = "Command to add project to project (p2p) reference",
|
||||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
AllowArgumentSeparator = true,
|
||||
ArgumentSeparatorHelpText = "Project to project references to add"
|
||||
ArgumentSeparatorHelpText = LocalizableStrings.AppHelpText
|
||||
};
|
||||
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
CommandArgument projectArgument = app.Argument(
|
||||
"<PROJECT>",
|
||||
"The project file to modify. If a project file is not specified," +
|
||||
" it searches the current working directory for an MSBuild file that has" +
|
||||
" a file extension that ends in `proj` and uses that file.");
|
||||
$"<{LocalizableStrings.CmdProject}>",
|
||||
LocalizableStrings.CmdProjectDescription);
|
||||
|
||||
CommandOption frameworkOption = app.Option(
|
||||
"-f|--framework <FRAMEWORK>",
|
||||
"Add reference only when targetting a specific framework",
|
||||
$"-f|--framework <{LocalizableStrings.CmdFramework}>",
|
||||
LocalizableStrings.CmdFrameworkDescription,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption forceOption = app.Option(
|
||||
"--force",
|
||||
"Add reference even if it does not exist, do not convert paths to relative",
|
||||
LocalizableStrings.CmdForceDescription,
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
app.OnExecute(() => {
|
||||
if (string.IsNullOrEmpty(projectArgument.Value))
|
||||
{
|
||||
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, "<Project>");
|
||||
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, $"<{LocalizableStrings.ProjectException}>");
|
||||
}
|
||||
|
||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(projectArgument.Value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue