dotnet / dotnet/command-line-api
Argument<DirectoryInfo> with default value isn't validated with ExistingOnly()
Open
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
In the following example, if an argument is NOT provided then the `.ExistingOnly()` requirement is not applied:
```csharp
new Option(new[] {"--output", "-o"}, "folder to output the things to")
{
Argument = new Argument(() => new DirectoryInfo("things"))
{
Arity = ArgumentArity.ExactlyOne
}.ExistingOnly()
}
```
In the above, the folder named `things` does not exists so a validation error was expected but was not raised.
Whereas if an argument is passed which refers to a non-existent folder then I get the expected error:
```
Directory does not exist: folder-which-does-not-exist
```
Contributor guide
Assessment
This issue has not been assessed yet.