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 => internal override Dictionary<string, Func<AppliedOption, CommandBase>> SubCommands =>
new Dictionary<string, Func<AppliedOption, CommandBase>> new Dictionary<string, Func<AppliedOption, CommandBase>>
{ {
{ "add", o => new AddProjectToSolutionCommand(o) }, ["add"] =
{ "list", o => new ListProjectsInSolutionCommand(o) }, sln => new AddProjectToSolutionCommand(
{ "remove", o => new RemoveProjectFromSolutionCommand(o) } 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) public static int Run(string[] args)

View file

@ -8,8 +8,11 @@ namespace Microsoft.DotNet.Cli
internal static class SlnCommandParser internal static class SlnCommandParser
{ {
public static Command Sln() => public static Command Sln() =>
Create.Command("sln", Create.Command(
"sln",
".NET modify solution file command", ".NET modify solution file command",
Accept.ExactlyOneArgument()
.DefaultToCurrentDirectory(),
CommonOptions.HelpOption(), CommonOptions.HelpOption(),
Create.Command("add", Create.Command("add",
".NET Add project(s) to a solution file Command", ".NET Add project(s) to a solution file Command",

View file

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

View file

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

View file

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