Skip to content
Next Next commit
Rename to AcceptExistingOnly
  • Loading branch information
jozkee committed Nov 8, 2022
commit 869e59e22ab5aaf45801ea416ecda896bfe6659e
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ System.CommandLine
public System.Boolean Equals(System.Object obj)
public System.Int32 GetHashCode()
public static class ArgumentExtensions
public static Argument<System.IO.FileInfo> AcceptExistingOnly(this Argument<System.IO.FileInfo> argument)
public static Argument<System.IO.DirectoryInfo> AcceptExistingOnly(this Argument<System.IO.DirectoryInfo> argument)
public static Argument<System.IO.FileSystemInfo> AcceptExistingOnly(this Argument<System.IO.FileSystemInfo> argument)
public static Argument<T> AcceptExistingOnly<T>(this Argument<T> argument)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.String[] values)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>> complete)
public static Argument<System.IO.FileInfo> ExistingOnly(this Argument<System.IO.FileInfo> argument)
public static Argument<System.IO.DirectoryInfo> ExistingOnly(this Argument<System.IO.DirectoryInfo> argument)
public static Argument<System.IO.FileSystemInfo> ExistingOnly(this Argument<System.IO.FileSystemInfo> argument)
public static Argument<T> ExistingOnly<T>(this Argument<T> argument)
public static TArgument FromAmong<TArgument>(this TArgument argument, System.String[] values)
public static TArgument LegalFileNamesOnly<TArgument>(this TArgument argument)
public static TArgument LegalFilePathsOnly<TArgument>(this TArgument argument)
Expand Down Expand Up @@ -208,13 +208,13 @@ System.CommandLine
.ctor(System.String[] aliases, Func<T> defaultValueFactory, System.String description = null)
public ArgumentArity Arity { get; set; }
public static class OptionExtensions
public static Option<System.IO.FileInfo> AcceptExistingOnly(this Option<System.IO.FileInfo> option)
public static Option<System.IO.DirectoryInfo> AcceptExistingOnly(this Option<System.IO.DirectoryInfo> option)
public static Option<System.IO.FileSystemInfo> AcceptExistingOnly(this Option<System.IO.FileSystemInfo> option)
public static Option<T> AcceptExistingOnly<T>(this Option<T> option)
public static TOption AddCompletions<TOption>(this TOption option, System.String[] values)
public static TOption AddCompletions<TOption>(this TOption option, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static TOption AddCompletions<TOption>(this TOption option, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>> complete)
public static Option<System.IO.FileInfo> ExistingOnly(this Option<System.IO.FileInfo> option)
public static Option<System.IO.DirectoryInfo> ExistingOnly(this Option<System.IO.DirectoryInfo> option)
public static Option<System.IO.FileSystemInfo> ExistingOnly(this Option<System.IO.FileSystemInfo> option)
public static Option<T> ExistingOnly<T>(this Option<T> option)
public static TOption FromAmong<TOption>(this TOption option, System.String[] values)
public static TOption LegalFileNamesOnly<TOption>(this TOption option)
public static TOption LegalFilePathsOnly<TOption>(this TOption option)
Expand Down
36 changes: 18 additions & 18 deletions src/System.CommandLine.Tests/ParsingValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public void A_command_argument_can_be_invalid_based_on_file_existence()
{
var command = new Command("move")
{
new Argument<FileInfo>("to").ExistingOnly()
new Argument<FileInfo>("to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -700,7 +700,7 @@ public void An_option_argument_can_be_invalid_based_on_file_existence()
{
var command = new Command("move")
{
new Option<FileInfo>("--to").ExistingOnly()
new Option<FileInfo>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -719,7 +719,7 @@ public void A_command_argument_can_be_invalid_based_on_directory_existence()
{
var command = new Command("move")
{
new Argument<DirectoryInfo>("to").ExistingOnly()
new Argument<DirectoryInfo>("to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -738,7 +738,7 @@ public void An_option_argument_can_be_invalid_based_on_directory_existence()
{
var command = new Command("move")
{
new Option<DirectoryInfo>("--to").ExistingOnly()
new Option<DirectoryInfo>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -757,7 +757,7 @@ public void A_command_argument_can_be_invalid_based_on_file_or_directory_existen
{
var command = new Command("move")
{
new Argument<FileSystemInfo>().ExistingOnly()
new Argument<FileSystemInfo>().AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -776,7 +776,7 @@ public void An_option_argument_can_be_invalid_based_on_file_or_directory_existen
{
var command = new Command("move")
{
new Option<FileSystemInfo>("--to").ExistingOnly()
new Option<FileSystemInfo>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -795,7 +795,7 @@ public void A_command_argument_with_multiple_files_can_be_invalid_based_on_file_
{
var command = new Command("move")
{
new Argument<IEnumerable<FileInfo>>("to").ExistingOnly()
new Argument<IEnumerable<FileInfo>>("to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -814,7 +814,7 @@ public void An_option_argument_with_multiple_files_can_be_invalid_based_on_file_
{
var command = new Command("move")
{
new Option<IEnumerable<FileInfo>>("--to").ExistingOnly()
new Option<IEnumerable<FileInfo>>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -833,7 +833,7 @@ public void A_command_argument_with_multiple_directories_can_be_invalid_based_on
{
var command = new Command("move")
{
new Argument<List<DirectoryInfo>>("to").ExistingOnly()
new Argument<List<DirectoryInfo>>("to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -852,7 +852,7 @@ public void An_option_argument_with_multiple_directories_can_be_invalid_based_on
{
var command = new Command("move")
{
new Option<DirectoryInfo[]>("--to").ExistingOnly()
new Option<DirectoryInfo[]>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -874,7 +874,7 @@ public void A_command_argument_with_multiple_FileSystemInfos_can_be_invalid_base
new Argument<FileSystemInfo[]>("to")
{
Arity = ArgumentArity.ZeroOrMore
}.ExistingOnly(),
}.AcceptExistingOnly(),
new Option<string>("--to")
};

Expand All @@ -892,7 +892,7 @@ public void An_option_argument_with_multiple_FileSystemInfos_can_be_invalid_base
{
var command = new Command("move")
{
new Option<FileSystemInfo[]>("--to").ExistingOnly()
new Option<FileSystemInfo[]>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -911,7 +911,7 @@ public void A_command_argument_with_multiple_FileSystemInfos_can_be_invalid_base
{
var command = new Command("move")
{
new Argument<FileSystemInfo>("to").ExistingOnly()
new Argument<FileSystemInfo>("to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -930,7 +930,7 @@ public void An_option_argument_with_multiple_FileSystemInfos_can_be_invalid_base
{
var command = new Command("move")
{
new Option<FileSystemInfo[]>("--to").ExistingOnly()
new Option<FileSystemInfo[]>("--to").AcceptExistingOnly()
};

var path = NonexistentPath();
Expand All @@ -949,7 +949,7 @@ public void Command_argument_does_not_return_errors_when_file_exists()
{
var command = new Command("move")
{
new Argument<FileInfo>().ExistingOnly()
new Argument<FileInfo>().AcceptExistingOnly()
};

var path = ExistingFile();
Expand All @@ -963,7 +963,7 @@ public void Option_argument_does_not_return_errors_when_file_exists()
{
var command = new Command("move")
{
new Option<FileInfo>("--to").ExistingOnly()
new Option<FileInfo>("--to").AcceptExistingOnly()
};

var path = ExistingFile();
Expand All @@ -977,7 +977,7 @@ public void Command_argument_does_not_return_errors_when_Directory_exists()
{
var command = new Command("move")
{
new Argument<DirectoryInfo>().ExistingOnly()
new Argument<DirectoryInfo>().AcceptExistingOnly()
};

var path = ExistingDirectory();
Expand All @@ -991,7 +991,7 @@ public void Option_argument_does_not_return_errors_when_Directory_exists()
{
var command = new Command("move")
{
new Option<DirectoryInfo>("--to").ExistingOnly()
new Option<DirectoryInfo>("--to").AcceptExistingOnly()
};

var path = ExistingDirectory();
Expand Down
8 changes: 4 additions & 4 deletions src/System.CommandLine/ArgumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static TArgument FromAmong<TArgument>(
/// </summary>
/// <param name="argument">The argument to configure.</param>
/// <returns>The configured argument.</returns>
public static Argument<FileInfo> ExistingOnly(this Argument<FileInfo> argument)
public static Argument<FileInfo> AcceptExistingOnly(this Argument<FileInfo> argument)
{
argument.AddValidator(Validate.FileExists);
return argument;
Expand All @@ -100,7 +100,7 @@ public static Argument<FileInfo> ExistingOnly(this Argument<FileInfo> argument)
/// </summary>
/// <param name="argument">The argument to configure.</param>
/// <returns>The configured argument.</returns>
public static Argument<DirectoryInfo> ExistingOnly(this Argument<DirectoryInfo> argument)
public static Argument<DirectoryInfo> AcceptExistingOnly(this Argument<DirectoryInfo> argument)
{
argument.AddValidator(Validate.DirectoryExists);
return argument;
Expand All @@ -111,7 +111,7 @@ public static Argument<DirectoryInfo> ExistingOnly(this Argument<DirectoryInfo>
/// </summary>
/// <param name="argument">The argument to configure.</param>
/// <returns>The configured argument.</returns>
public static Argument<FileSystemInfo> ExistingOnly(this Argument<FileSystemInfo> argument)
public static Argument<FileSystemInfo> AcceptExistingOnly(this Argument<FileSystemInfo> argument)
{
argument.AddValidator(Validate.FileOrDirectoryExists);
return argument;
Expand All @@ -122,7 +122,7 @@ public static Argument<FileSystemInfo> ExistingOnly(this Argument<FileSystemInfo
/// </summary>
/// <param name="argument">The argument to configure.</param>
/// <returns>The configured argument.</returns>
public static Argument<T> ExistingOnly<T>(this Argument<T> argument)
public static Argument<T> AcceptExistingOnly<T>(this Argument<T> argument)
where T : IEnumerable<FileSystemInfo>
{
if (typeof(IEnumerable<FileInfo>).IsAssignableFrom(typeof(T)))
Expand Down
10 changes: 5 additions & 5 deletions src/System.CommandLine/OptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static TOption AddCompletions<TOption>(
/// </summary>
/// <param name="option">The option to configure.</param>
/// <returns>The option being extended.</returns>
public static Option<FileInfo> ExistingOnly(this Option<FileInfo> option)
public static Option<FileInfo> AcceptExistingOnly(this Option<FileInfo> option)
{
option.Argument.AddValidator(Validate.FileExists);
return option;
Expand All @@ -100,7 +100,7 @@ public static Option<FileInfo> ExistingOnly(this Option<FileInfo> option)
/// </summary>
/// <param name="option">The option to configure.</param>
/// <returns>The option being extended.</returns>
public static Option<DirectoryInfo> ExistingOnly(this Option<DirectoryInfo> option)
public static Option<DirectoryInfo> AcceptExistingOnly(this Option<DirectoryInfo> option)
{
option.Argument.AddValidator(Validate.DirectoryExists);
return option;
Expand All @@ -111,7 +111,7 @@ public static Option<DirectoryInfo> ExistingOnly(this Option<DirectoryInfo> opti
/// </summary>
/// <param name="option">The option to configure.</param>
/// <returns>The option being extended.</returns>
public static Option<FileSystemInfo> ExistingOnly(this Option<FileSystemInfo> option)
public static Option<FileSystemInfo> AcceptExistingOnly(this Option<FileSystemInfo> option)
{
option.Argument.AddValidator(Validate.FileOrDirectoryExists);
return option;
Expand All @@ -122,12 +122,12 @@ public static Option<FileSystemInfo> ExistingOnly(this Option<FileSystemInfo> op
/// </summary>
/// <param name="option">The option to configure.</param>
/// <returns>The option being extended.</returns>
public static Option<T> ExistingOnly<T>(this Option<T> option)
public static Option<T> AcceptExistingOnly<T>(this Option<T> option)
where T : IEnumerable<FileSystemInfo>
{
if (option.Argument is Argument<T> arg)
{
arg.ExistingOnly();
arg.AcceptExistingOnly();
}

return option;
Expand Down