correct arguments for dotnet sln commands

This commit is contained in:
Jon Sequeira 2017-03-11 11:47:04 -08:00
parent 86f26550f1
commit 5c4db56d3b
5 changed files with 39 additions and 24 deletions

View file

@ -22,9 +22,21 @@ namespace Microsoft.DotNet.Tools.Sln
internal override Dictionary<string, Func<AppliedOption, CommandBase>> SubCommands =>
new Dictionary<string, Func<AppliedOption, CommandBase>>
{
{ "add", o => new AddProjectToSolutionCommand(o) },
{ "list", o => new ListProjectsInSolutionCommand(o) },
{ "remove", o => new RemoveProjectFromSolutionCommand(o) }
["add"] =
sln => new AddProjectToSolutionCommand(
sln["add"],
sln.Value<string>()),
["list"] =
sln => new ListProjectsInSolutionCommand(
sln["list"],
sln.Value<string>()),
["remove"] =
sln =>
new RemoveProjectFromSolutionCommand(
sln["remove"],
sln.Value<string>())
};
public static int Run(string[] args)

View file

@ -8,20 +8,23 @@ namespace Microsoft.DotNet.Cli
internal static class SlnCommandParser
{
public static Command Sln() =>
Create.Command("sln",
".NET modify solution file command",
CommonOptions.HelpOption(),
Create.Command("add",
".NET Add project(s) to a solution file Command",
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("list",
"List all projects in the solution.",
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("remove",
"Remove the specified project(s) from the solution. The project is not impacted."));
Create.Command(
"sln",
".NET modify solution file command",
Accept.ExactlyOneArgument()
.DefaultToCurrentDirectory(),
CommonOptions.HelpOption(),
Create.Command("add",
".NET Add project(s) to a solution file Command",
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("list",
"List all projects in the solution.",
Accept.ExactlyOneArgument()
.With(name: "SLN_FILE"),
CommonOptions.HelpOption()),
Create.Command("remove",
"Remove the specified project(s) from the solution. The project is not impacted."));
}
}

View file

@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tools.Sln.Add
private readonly AppliedOption _appliedCommand;
private readonly string _fileOrDirectory;
public AddProjectToSolutionCommand(AppliedOption appliedCommand)
public AddProjectToSolutionCommand(AppliedOption appliedCommand, string fileOrDirectory)
{
if (appliedCommand == null)
{
@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Tools.Sln.Add
}
_appliedCommand = appliedCommand;
_fileOrDirectory = appliedCommand.Arguments.Single();
_fileOrDirectory = fileOrDirectory;
}
public override int Execute()

View file

@ -15,13 +15,13 @@ namespace Microsoft.DotNet.Tools.Sln.List
{
private readonly string _fileOrDirectory;
public ListProjectsInSolutionCommand(AppliedOption appliedCommand)
public ListProjectsInSolutionCommand(AppliedOption appliedCommand, string fileOrDirectory)
{
if (appliedCommand == null)
{
throw new ArgumentNullException(nameof(appliedCommand));
}
_fileOrDirectory = appliedCommand.Arguments.Single();
_fileOrDirectory = fileOrDirectory;
}
public override int Execute()

View file

@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tools.Sln.Remove
private readonly AppliedOption _appliedCommand;
private readonly string _fileOrDirectory;
public RemoveProjectFromSolutionCommand(AppliedOption appliedCommand)
public RemoveProjectFromSolutionCommand(AppliedOption appliedCommand, string fileOrDirectory)
{
if (appliedCommand == null)
{
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Tools.Sln.Remove
}
_appliedCommand = appliedCommand;
_fileOrDirectory = appliedCommand.Arguments.Single();
_fileOrDirectory = fileOrDirectory;
}
public override int Execute()