Squash
This commit is contained in:
parent
29b824a6ff
commit
e249d4a0bc
2 changed files with 57 additions and 12 deletions
39
src/dotnet/commands/dotnet-new/LocalizableStrings.cs
Normal file
39
src/dotnet/commands/dotnet-new/LocalizableStrings.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
namespace Microsoft.DotNet.Tools.New
|
||||
{
|
||||
internal class LocalizableStrings
|
||||
{
|
||||
public const string CreatingNewError = "Creating new ";
|
||||
|
||||
public const string CreatedNew = "Created new ";
|
||||
|
||||
public const string CreatingNewError2 = " project failed, project already exists.";
|
||||
|
||||
public const string DirectoryContainsError = " project failed, directory already contains ";
|
||||
|
||||
public const string ProjectFailedError = " project failed.";
|
||||
|
||||
public const string ProjectIn = " project in ";
|
||||
|
||||
public const string AppFullName = ".NET Initializer";
|
||||
|
||||
public const string AppDescription = "Initializes empty project for .NET Platform";
|
||||
|
||||
public const string ValidValuesText = "Valid values for ";
|
||||
|
||||
public const string Language = "LANGUAGE";
|
||||
|
||||
public const string LanguageOfProject = "Language of project";
|
||||
|
||||
public const string ValidValues = "Valid values";
|
||||
|
||||
public const string Type = "TYPE";
|
||||
|
||||
public const string TypeOfProject = "Type of project";
|
||||
|
||||
public const string UnrecognizedLanguage = "Unrecognized language";
|
||||
|
||||
public const string UnrecognizedType = "Unrecognized type";
|
||||
|
||||
public const string AvailableTypes = "Available types for";
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ namespace Microsoft.DotNet.Tools.New
|
|||
// Check if project.json exists in the folder
|
||||
if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "project.json")) && !isMsBuild)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Creating new {languageName} project failed, project already exists.");
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.CreatingNewError}{languageName}{LocalizableStrings.CreatingNewError2}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace Microsoft.DotNet.Tools.New
|
|||
{
|
||||
if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), entry)))
|
||||
{
|
||||
Reporter.Error.WriteLine($"Creating new {languageName} project failed, directory already contains {entry}");
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.CreatingNewError}{languageName}{LocalizableStrings.DirectoryContainsError}{entry}");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -86,11 +86,11 @@ namespace Microsoft.DotNet.Tools.New
|
|||
|
||||
if (hasFilesToOverride)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Creating new {languageName} project failed.");
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.CreatingNewError}{languageName}{LocalizableStrings.ProjectFailedError}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reporter.Output.WriteLine($"Created new {languageName} project in {Directory.GetCurrentDirectory()}.");
|
||||
Reporter.Output.WriteLine($"{LocalizableStrings.CreatedNew}{languageName}{LocalizableStrings.ProjectIn}{Directory.GetCurrentDirectory()}.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ namespace Microsoft.DotNet.Tools.New
|
|||
|
||||
var app = new CommandLineApplication();
|
||||
app.Name = "dotnet new";
|
||||
app.FullName = ".NET Initializer";
|
||||
app.Description = "Initializes empty project for .NET Platform";
|
||||
app.FullName = LocalizableStrings.AppFullName;
|
||||
app.Description = LocalizableStrings.AppDescription;
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
var csharp = new { Name = "C#", Alias = new[] { "c#", "cs", "csharp" }, TemplatePrefix = "CSharp",
|
||||
|
@ -160,11 +160,17 @@ namespace Microsoft.DotNet.Tools.New
|
|||
var typeValues =
|
||||
from l in languages
|
||||
let values = string.Join(", ", l.Templates.Select(t => t.Name))
|
||||
select $"Valid values for {l.Name}: {values}.";
|
||||
select $"{LocalizableStrings.ValidValuesText}{l.Name}: {values}.";
|
||||
string typeValuesString = string.Join(" ", typeValues);
|
||||
|
||||
var lang = app.Option("-l|--lang <LANGUAGE>", $"Language of project Valid values: {langValuesString}.", CommandOptionType.SingleValue);
|
||||
var type = app.Option("-t|--type <TYPE>", $"Type of project {typeValuesString}", CommandOptionType.SingleValue);
|
||||
var lang = app.Option(
|
||||
$"-l|--lang <{LocalizableStrings.Language}>",
|
||||
$"{LocalizableStrings.LanguageOfProject} {LocalizableStrings.ValidValues}: {langValuesString}.",
|
||||
CommandOptionType.SingleValue);
|
||||
var type = app.Option(
|
||||
$"-t|--type <{LocalizableStrings.Type}>",
|
||||
$"{LocalizableStrings.TypeOfProject} {typeValuesString}",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var dotnetNew = new NewCommand();
|
||||
app.OnExecute(() =>
|
||||
|
@ -176,7 +182,7 @@ namespace Microsoft.DotNet.Tools.New
|
|||
|
||||
if (language == null)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unrecognized language: {languageValue}".Red());
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.UnrecognizedLanguage}: {languageValue}".Red());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -185,8 +191,8 @@ namespace Microsoft.DotNet.Tools.New
|
|||
var template = language.Templates.FirstOrDefault(t => StringComparer.OrdinalIgnoreCase.Equals(typeValue, t.Name));
|
||||
if (template == null)
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unrecognized type: {typeValue}".Red());
|
||||
Reporter.Error.WriteLine($"Available types for {language.Name} :".Red());
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.UnrecognizedType}: {typeValue}".Red());
|
||||
Reporter.Error.WriteLine($"{LocalizableStrings.AvailableTypes} {language.Name} :".Red());
|
||||
foreach (var t in language.Templates)
|
||||
{
|
||||
Reporter.Error.WriteLine($"- {t}".Red());
|
||||
|
|
Loading…
Reference in a new issue