Address PR comments
This commit is contained in:
parent
ae1e183e41
commit
917154fd5d
3 changed files with 18 additions and 11 deletions
|
@ -56,28 +56,33 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
||||||
public bool HandleRemainingArguments { get; set; }
|
public bool HandleRemainingArguments { get; set; }
|
||||||
public string ArgumentSeparatorHelpText { get; set; }
|
public string ArgumentSeparatorHelpText { get; set; }
|
||||||
|
|
||||||
public CommandLineApplication Command(string name, bool throwOnUnexpectedArg = true)
|
public CommandLineApplication AddCommand(string name, bool throwOnUnexpectedArg = true)
|
||||||
{
|
{
|
||||||
return Command(name, _ => { }, throwOnUnexpectedArg);
|
return AddCommand(name, _ => { }, throwOnUnexpectedArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLineApplication Command(string name, Action<CommandLineApplication> configuration,
|
public CommandLineApplication AddCommand(string name, Action<CommandLineApplication> configuration,
|
||||||
bool throwOnUnexpectedArg = true)
|
bool throwOnUnexpectedArg = true)
|
||||||
{
|
{
|
||||||
var command = new CommandLineApplication(throwOnUnexpectedArg) { Name = name };
|
var command = new CommandLineApplication(throwOnUnexpectedArg) { Name = name };
|
||||||
return Command(command, configuration, throwOnUnexpectedArg);
|
return AddCommand(command, configuration, throwOnUnexpectedArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLineApplication Command(CommandLineApplication command, bool throwOnUnexpectedArg = true)
|
public CommandLineApplication AddCommand(CommandLineApplication command, bool throwOnUnexpectedArg = true)
|
||||||
{
|
{
|
||||||
return Command(command, _ => { }, throwOnUnexpectedArg);
|
return AddCommand(command, _ => { }, throwOnUnexpectedArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLineApplication Command(
|
public CommandLineApplication AddCommand(
|
||||||
CommandLineApplication command,
|
CommandLineApplication command,
|
||||||
Action<CommandLineApplication> configuration,
|
Action<CommandLineApplication> configuration,
|
||||||
bool throwOnUnexpectedArg = true)
|
bool throwOnUnexpectedArg = true)
|
||||||
{
|
{
|
||||||
|
if (command == null || configuration == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException();
|
||||||
|
}
|
||||||
|
|
||||||
command.Parent = this;
|
command.Parent = this;
|
||||||
Commands.Add(command);
|
Commands.Add(command);
|
||||||
configuration(command);
|
configuration(command);
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
foreach (var subCommandCreator in SubCommands)
|
foreach (var subCommandCreator in SubCommands)
|
||||||
{
|
{
|
||||||
var subCommand = subCommandCreator();
|
var subCommand = subCommandCreator();
|
||||||
command.Command(subCommand);
|
command.AddCommand(subCommand);
|
||||||
|
|
||||||
subCommand.OnExecute(() => {
|
subCommand.OnExecute(() => {
|
||||||
try
|
try
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
|
|
||||||
public override int Run(string fileOrDirectory)
|
public override int Run(string fileOrDirectory)
|
||||||
{
|
{
|
||||||
ProjectCollection projects = new ProjectCollection();
|
var projects = new ProjectCollection();
|
||||||
MsbuildProject msbuildProj = MsbuildProject.FromFileOrDirectory(projects, fileOrDirectory);
|
MsbuildProject msbuildProj = MsbuildProject.FromFileOrDirectory(projects, fileOrDirectory);
|
||||||
|
|
||||||
if (RemainingArguments.Count == 0)
|
if (RemainingArguments.Count == 0)
|
||||||
|
@ -51,7 +51,9 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
|
|
||||||
string frameworkString = _frameworkOption.Value();
|
string frameworkString = _frameworkOption.Value();
|
||||||
PathUtility.EnsureAllPathsExist(RemainingArguments, CommonLocalizableStrings.ReferenceDoesNotExist);
|
PathUtility.EnsureAllPathsExist(RemainingArguments, CommonLocalizableStrings.ReferenceDoesNotExist);
|
||||||
IEnumerable<MsbuildProject> refs = RemainingArguments.Select((r) => MsbuildProject.FromFile(projects, r));
|
List<MsbuildProject> refs = RemainingArguments
|
||||||
|
.Select((r) => MsbuildProject.FromFile(projects, r))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (frameworkString == null)
|
if (frameworkString == null)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +110,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetProjectNotCompatibleWithFrameworksDisplayString(MsbuildProject project, IEnumerable<string> frameworksDisplayStrings)
|
private static string GetProjectNotCompatibleWithFrameworksDisplayString(MsbuildProject project, IEnumerable<string> frameworksDisplayStrings)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine(string.Format(CommonLocalizableStrings.ProjectNotCompatibleWithFrameworks, project.ProjectRootElement.FullPath));
|
sb.AppendLine(string.Format(CommonLocalizableStrings.ProjectNotCompatibleWithFrameworks, project.ProjectRootElement.FullPath));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue