text fixes, remove file existence validations from parse
This commit is contained in:
parent
9318e8f10d
commit
9c2e8f0037
4 changed files with 4 additions and 40 deletions
|
@ -64,41 +64,5 @@ namespace Microsoft.DotNet.Cli
|
|||
|
||||
public static ArgumentsRule DefaultToCurrentDirectory(this ArgumentsRule rule) =>
|
||||
rule.With(defaultValue: () => PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
|
||||
|
||||
public static ArgumentsRule ExistingFilesOnly(
|
||||
this ArgumentsRule rule) =>
|
||||
rule.And(new ArgumentsRule(o =>
|
||||
{
|
||||
foreach (var filePath in o.Arguments)
|
||||
{
|
||||
if (!File.Exists(filePath) &&
|
||||
!Directory.Exists(filePath))
|
||||
{
|
||||
return $"File not found: {filePath}";
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}));
|
||||
|
||||
public static ArgumentsRule ExistingSlnFileOrDirectoryOnly(
|
||||
this ArgumentsRule rule) =>
|
||||
rule
|
||||
.ExistingFilesOnly()
|
||||
.And(new ArgumentsRule(o =>
|
||||
{
|
||||
foreach (var path in o.Arguments)
|
||||
{
|
||||
if (path.HasExtension(".sln") ||
|
||||
path.IsDirectory())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return $"Specified path '{path}' is not a directory or solution file.";
|
||||
}
|
||||
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@ namespace Microsoft.DotNet.Cli
|
|||
"add",
|
||||
".NET Add Command",
|
||||
Accept.ExactlyOneArgument()
|
||||
.ExistingFilesOnly()
|
||||
.DefaultToCurrentDirectory()
|
||||
.With(name: "PROJECT",
|
||||
description: "The project file to operate on. If a file is not specified, the command will search the current directory for one."),
|
||||
|
|
|
@ -112,8 +112,8 @@ Options:
|
|||
.WithProject("one two three")
|
||||
.Execute("proj.csproj");
|
||||
cmd.ExitCode.Should().NotBe(0);
|
||||
cmd.StdErr.Should().Be("Unrecognized command or argument 'two'");
|
||||
cmd.StdOut.Should().Be("Specify --help for a list of available options and commands.");
|
||||
cmd.StdErr.Should().BeVisuallyEquivalentTo(
|
||||
"Unrecognized command or argument 'two'\r\nUnrecognized command or argument 'three'");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -57,7 +57,8 @@ Options:
|
|||
.WithProject("one two three")
|
||||
.Execute("proj.csproj");
|
||||
cmd.ExitCode.Should().NotBe(0);
|
||||
cmd.StdErr.Should().Be("Unrecognized command or argument 'two'");
|
||||
cmd.StdErr.Should().BeVisuallyEquivalentTo(
|
||||
"Unrecognized command or argument 'one'\r\nUnrecognized command or argument 'two'\r\nUnrecognized command or argument 'three'");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
Loading…
Reference in a new issue