@@ -57,11 +57,13 @@ static CommandLineApplication()
57
57
private readonly ConventionContext _conventionContext ;
58
58
private readonly List < IConvention > _conventions = new List < IConvention > ( ) ;
59
59
60
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
60
61
/// <summary>
61
62
/// Initializes a new instance of <see cref="CommandLineApplication"/>.
62
63
/// </summary>
63
64
/// <param name="throwOnUnexpectedArg">Initial value for <see cref="ThrowOnUnexpectedArgument"/>.</param>
64
65
public CommandLineApplication ( bool throwOnUnexpectedArg = true )
66
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
65
67
: this ( null , DefaultHelpTextGenerator . Singleton , new DefaultCommandLineContext ( ) , throwOnUnexpectedArg )
66
68
{
67
69
}
@@ -470,6 +472,7 @@ private void AssertCommandNameIsUnique(string? name, CommandLineApplication? com
470
472
}
471
473
}
472
474
475
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
473
476
/// <summary>
474
477
/// Adds a subcommand.
475
478
/// </summary>
@@ -478,6 +481,7 @@ private void AssertCommandNameIsUnique(string? name, CommandLineApplication? com
478
481
/// <param name="throwOnUnexpectedArg"></param>
479
482
/// <returns></returns>
480
483
public CommandLineApplication Command ( string name , Action < CommandLineApplication > configuration ,
484
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
481
485
bool throwOnUnexpectedArg = true )
482
486
{
483
487
var command = new CommandLineApplication ( this , name , throwOnUnexpectedArg ) ;
@@ -489,6 +493,7 @@ public CommandLineApplication Command(string name, Action<CommandLineApplication
489
493
return command ;
490
494
}
491
495
496
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
492
497
/// <summary>
493
498
/// Adds a subcommand with model of type <typeparamref name="TModel" />.
494
499
/// </summary>
@@ -498,6 +503,7 @@ public CommandLineApplication Command(string name, Action<CommandLineApplication
498
503
/// <typeparam name="TModel">The model type of the subcommand.</typeparam>
499
504
/// <returns></returns>
500
505
public CommandLineApplication < TModel > Command < TModel > ( string name , Action < CommandLineApplication < TModel > > configuration ,
506
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
501
507
bool throwOnUnexpectedArg = true )
502
508
where TModel : class
503
509
{
@@ -592,6 +598,7 @@ public CommandOption<T> Option<T>(string template, string description, CommandOp
592
598
return option ;
593
599
}
594
600
601
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
595
602
/// <summary>
596
603
/// Adds a command line argument
597
604
/// </summary>
@@ -600,8 +607,10 @@ public CommandOption<T> Option<T>(string template, string description, CommandOp
600
607
/// <param name="multipleValues"></param>
601
608
/// <returns></returns>
602
609
public CommandArgument Argument ( string name , string description , bool multipleValues = false )
610
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
603
611
=> Argument ( name , description , _ => { } , multipleValues ) ;
604
612
613
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
605
614
/// <summary>
606
615
/// Adds a command line argument.
607
616
/// </summary>
@@ -611,6 +620,7 @@ public CommandArgument Argument(string name, string description, bool multipleVa
611
620
/// <param name="multipleValues"></param>
612
621
/// <returns></returns>
613
622
public CommandArgument Argument ( string name , string description , Action < CommandArgument > configuration , bool multipleValues = false )
623
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
614
624
{
615
625
var argument = new CommandArgument
616
626
{
@@ -623,6 +633,7 @@ public CommandArgument Argument(string name, string description, Action<CommandA
623
633
return argument ;
624
634
}
625
635
636
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
626
637
/// <summary>
627
638
/// Adds a command line argument with values that should be parsable into <typeparamref name="T" />.
628
639
/// </summary>
@@ -633,6 +644,7 @@ public CommandArgument Argument(string name, string description, Action<CommandA
633
644
/// <typeparam name="T">The type of the values on the option</typeparam>
634
645
/// <returns></returns>
635
646
public CommandArgument < T > Argument < T > ( string name , string description , Action < CommandArgument > configuration , bool multipleValues = false )
647
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
636
648
{
637
649
var parser = ValueParsers . GetParser < T > ( ) ;
638
650
@@ -801,6 +813,7 @@ public int Execute(params string[] args)
801
813
return ExecuteAsync ( args ) . GetAwaiter ( ) . GetResult ( ) ;
802
814
}
803
815
816
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
804
817
/// <summary>
805
818
/// Parses an array of strings using <see cref="Parse(string[])"/>.
806
819
/// <para>
@@ -820,6 +833,7 @@ public int Execute(params string[] args)
820
833
/// <param name="cancellationToken"></param>
821
834
/// <returns>The return code from <see cref="Invoke"/>.</returns>
822
835
public async Task < int > ExecuteAsync ( string [ ] args , CancellationToken cancellationToken = default )
836
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
823
837
{
824
838
var parseResult = Parse ( args ) ;
825
839
var command = parseResult . SelectedCommand ;
@@ -900,6 +914,7 @@ public CommandOption HelpOption(string template, bool inherited)
900
914
return OptionHelp ;
901
915
}
902
916
917
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
903
918
/// <summary>
904
919
/// Helper method that adds a version option from known versions strings.
905
920
/// </summary>
@@ -908,6 +923,7 @@ public CommandOption HelpOption(string template, bool inherited)
908
923
/// <param name="longFormVersion"></param>
909
924
/// <returns></returns>
910
925
public CommandOption VersionOption ( string template ,
926
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
911
927
string ? shortFormVersion ,
912
928
string ? longFormVersion = null )
913
929
{
@@ -921,6 +937,7 @@ public CommandOption VersionOption(string template,
921
937
}
922
938
}
923
939
940
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
924
941
/// <summary>
925
942
/// Helper method that adds a version option.
926
943
/// </summary>
@@ -929,6 +946,7 @@ public CommandOption VersionOption(string template,
929
946
/// <param name="longFormVersionGetter"></param>
930
947
/// <returns></returns>
931
948
public CommandOption VersionOption ( string template ,
949
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
932
950
Func < string ? > ? shortFormVersionGetter ,
933
951
Func < string ? > ? longFormVersionGetter = null )
934
952
{
@@ -995,7 +1013,9 @@ public void ShowHelp(bool usePager)
995
1013
[ Obsolete ( "This method has been marked as obsolete and will be removed in a future version. " +
996
1014
"The recommended replacement is ShowHelp()" ) ]
997
1015
[ EditorBrowsable ( EditorBrowsableState . Never ) ]
1016
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
998
1017
public void ShowHelp ( string ? commandName = null )
1018
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
999
1019
{
1000
1020
if ( commandName == null )
1001
1021
{
0 commit comments