diff --git a/src/dotnet/commands/dotnet-add/LocalizableStrings.cs b/src/dotnet/commands/dotnet-add/LocalizableStrings.cs new file mode 100644 index 000000000..bc8e581b9 --- /dev/null +++ b/src/dotnet/commands/dotnet-add/LocalizableStrings.cs @@ -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 ."; + + public const string ArgsDefinition = "Any extra arguments passed to the command. Use `dotnet add --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"; + } +} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/Program.cs b/src/dotnet/commands/dotnet-add/Program.cs index d8afe2593..5763f1edf 100644 --- a/src/dotnet/commands/dotnet-add/Program.cs +++ b/src/dotnet/commands/dotnet-add/Program.cs @@ -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] [[--] ...]] +{LocalizableStrings.Usage}: dotnet add [options] [[--] ...]] -Options: - -h|--help Show help information +{LocalizableStrings.Options}: + -h|--help {LocalizableStrings.HelpDefinition} -Arguments: - The object of the operation. If a project file is not specified, it defaults to the current directory. - Command to be executed on . +{LocalizableStrings.Arguments}: + {LocalizableStrings.ArgumentsObjectDefinition} + {LocalizableStrings.ArgumentsCommandDefinition} Args: - Any extra arguments passed to the command. Use `dotnet add --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> BuiltInCommands => new Dictionary> { diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-p2p/LocalizableStrings.cs b/src/dotnet/commands/dotnet-add/dotnet-add-p2p/LocalizableStrings.cs index e3dfd3a8a..76637a9fb 100644 --- a/src/dotnet/commands/dotnet-add/dotnet-add-p2p/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-add/dotnet-add-p2p/LocalizableStrings.cs @@ -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"; } } \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-p2p/Program.cs b/src/dotnet/commands/dotnet-add/dotnet-add-p2p/Program.cs index 163931266..581ea1d03 100644 --- a/src/dotnet/commands/dotnet-add/dotnet-add-p2p/Program.cs +++ b/src/dotnet/commands/dotnet-add/dotnet-add-p2p/Program.cs @@ -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( - "", - "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 ", - "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, ""); + throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, $"<{LocalizableStrings.ProjectException}>"); } var msbuildProj = MsbuildProject.FromFileOrDirectory(projectArgument.Value);