remove command fixes
This commit is contained in:
parent
bbc2722cb7
commit
c316b98c74
4 changed files with 33 additions and 10 deletions
|
@ -21,8 +21,15 @@ namespace Microsoft.DotNet.Tools.Remove
|
||||||
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>>
|
||||||
{
|
{
|
||||||
{ "reference", o => new RemoveProjectToProjectReferenceCommand(o) },
|
["reference"] =
|
||||||
{ "package", o => new RemovePackageReferenceCommand(o) }
|
remove => new RemoveProjectToProjectReferenceCommand(
|
||||||
|
remove["reference"],
|
||||||
|
remove.Value<string>()),
|
||||||
|
|
||||||
|
["package"] =
|
||||||
|
remove => new RemovePackageReferenceCommand(
|
||||||
|
remove["package"],
|
||||||
|
remove.Value<string>())
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int Run(string[] args)
|
public static int Run(string[] args)
|
||||||
|
|
|
@ -12,12 +12,15 @@ namespace Microsoft.DotNet.Cli
|
||||||
public static Command Remove() =>
|
public static Command Remove() =>
|
||||||
Create.Command("remove",
|
Create.Command("remove",
|
||||||
".NET Remove Command",
|
".NET Remove Command",
|
||||||
Accept.ZeroOrOneArgument()
|
Accept.ExactlyOneArgument()
|
||||||
|
.ExistingFilesOnly()
|
||||||
|
.DefaultToCurrentDirectory()
|
||||||
.With(name: "PROJECT",
|
.With(name: "PROJECT",
|
||||||
description: CommonLocalizableStrings.ArgumentsProjectDescription)
|
description: CommonLocalizableStrings.ArgumentsProjectDescription)
|
||||||
.DefaultToCurrentDirectory(),
|
.DefaultToCurrentDirectory(),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
Create.Command("package",
|
Create.Command(
|
||||||
|
"package",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
CommonOptions.HelpOption()),
|
CommonOptions.HelpOption()),
|
||||||
Create.Command(
|
Create.Command(
|
||||||
|
|
|
@ -16,19 +16,25 @@ namespace Microsoft.DotNet.Tools.Remove.PackageReference
|
||||||
private readonly AppliedOption _appliedCommand;
|
private readonly AppliedOption _appliedCommand;
|
||||||
private readonly string _fileOrDirectory;
|
private readonly string _fileOrDirectory;
|
||||||
|
|
||||||
public RemovePackageReferenceCommand(AppliedOption appliedCommand)
|
public RemovePackageReferenceCommand(
|
||||||
|
AppliedOption appliedCommand,
|
||||||
|
string fileOrDirectory)
|
||||||
{
|
{
|
||||||
if (appliedCommand == null)
|
if (appliedCommand == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(appliedCommand));
|
throw new ArgumentNullException(nameof(appliedCommand));
|
||||||
}
|
}
|
||||||
|
if (fileOrDirectory == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(fileOrDirectory));
|
||||||
|
}
|
||||||
if (_appliedCommand.Arguments.Count != 1)
|
if (_appliedCommand.Arguments.Count != 1)
|
||||||
{
|
{
|
||||||
throw new GracefulException(LocalizableStrings.SpecifyExactlyOnePackageReference);
|
throw new GracefulException(LocalizableStrings.SpecifyExactlyOnePackageReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
_appliedCommand = appliedCommand;
|
_appliedCommand = appliedCommand;
|
||||||
_fileOrDirectory = appliedCommand.Arguments.Single();
|
_fileOrDirectory = fileOrDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Execute()
|
public override int Execute()
|
||||||
|
|
|
@ -15,20 +15,27 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
|
||||||
private readonly AppliedOption _appliedCommand;
|
private readonly AppliedOption _appliedCommand;
|
||||||
private readonly string _fileOrDirectory;
|
private readonly string _fileOrDirectory;
|
||||||
|
|
||||||
public RemoveProjectToProjectReferenceCommand(AppliedOption appliedCommand)
|
public RemoveProjectToProjectReferenceCommand(
|
||||||
|
AppliedOption appliedCommand,
|
||||||
|
string fileOrDirectory)
|
||||||
{
|
{
|
||||||
if (appliedCommand == null)
|
if (appliedCommand == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(appliedCommand));
|
throw new ArgumentNullException(nameof(appliedCommand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fileOrDirectory == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(fileOrDirectory));
|
||||||
|
}
|
||||||
|
|
||||||
if (appliedCommand.Arguments.Count == 0)
|
if (appliedCommand.Arguments.Count == 0)
|
||||||
{
|
{
|
||||||
throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneReferenceToRemove);
|
throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneReferenceToRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
_appliedCommand = appliedCommand;
|
_appliedCommand = appliedCommand;
|
||||||
_fileOrDirectory = appliedCommand.Arguments.Single();
|
_fileOrDirectory = fileOrDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Execute()
|
public override int Execute()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue