You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* remove Argument.Parse as it has side effects: creating RootCommand and setting it as a Parent of given Argument
* remove Option.Parse as it has side effects: creating RootCommand and setting it as a Parent of given Option
* Move CommandExtensions.Parse to Command.Parse to make it easier to discover
* make Parser static
* move all extension methods from CommandLineBuilderExtensions to CommandLineBuilder itself, make it partial class to reduce diff size
* remove ParseResultExtensions.HasOption, as ParseResult.FindResultFor has all we need
* move ParseResultExtensions.Invoke* to ParseResult
* move CommandLineConfigurationExtensions to CommandLineConfiguration
* Apply suggestions from code review
---------
Co-authored-by: Kevin B <[email protected]>
Copy file name to clipboardExpand all lines: src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt
+35-45Lines changed: 35 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,6 @@ System.CommandLine
8
8
public System.Type ValueType { get; }
9
9
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
10
10
public System.Object GetDefaultValue()
11
-
public ParseResult Parse(System.String commandLine)
12
-
public ParseResult Parse(System.String[] args)
13
11
public System.String ToString()
14
12
public class Argument<T> : Argument, IValueDescriptor<T>, System.CommandLine.Binding.IValueDescriptor
15
13
.ctor()
@@ -56,44 +54,48 @@ System.CommandLine
56
54
public System.Void Add(Symbol symbol)
57
55
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
58
56
public System.Collections.Generic.IEnumerator<Symbol> GetEnumerator()
57
+
public ParseResult Parse(System.Collections.Generic.IReadOnlyList<System.String> args, CommandLineConfiguration configuration = null)
58
+
public ParseResult Parse(System.String commandLine, CommandLineConfiguration configuration = null)
public static TBuilder UseHelpBuilder<TBuilder>(this TBuilder builder, System.Func<System.CommandLine.Binding.BindingContext,System.CommandLine.Help.HelpBuilder> getHelpBuilder)
84
-
public static CommandLineBuilder UseParseDirective(this CommandLineBuilder builder, System.Int32 errorExitCode = 1)
85
-
public static CommandLineBuilder UseParseErrorReporting(this CommandLineBuilder builder, System.Int32 errorExitCode = 1)
86
-
public static CommandLineBuilder UseSuggestDirective(this CommandLineBuilder builder)
87
-
public static CommandLineBuilder UseTokenReplacer(this CommandLineBuilder builder, System.CommandLine.Parsing.TryReplaceToken replaceToken)
88
-
public static CommandLineBuilder UseTypoCorrections(this CommandLineBuilder builder, System.Int32 maxLevenshteinDistance = 3)
89
-
public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder)
90
-
public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder, System.String[] aliases)
67
+
public CommandLineBuilder AddMiddleware(System.CommandLine.Invocation.InvocationMiddleware middleware, System.CommandLine.Invocation.MiddlewareOrder order = Default)
68
+
public CommandLineBuilder AddMiddleware(System.Action<System.CommandLine.Invocation.InvocationContext> onInvoke, System.CommandLine.Invocation.MiddlewareOrder order = Default)
69
+
public CommandLineConfiguration Build()
70
+
public CommandLineBuilder CancelOnProcessTermination(System.Nullable<System.TimeSpan> timeout = null)
71
+
public CommandLineBuilder EnableDirectives(System.Boolean value = True)
72
+
public CommandLineBuilder EnablePosixBundling(System.Boolean value = True)
73
+
public CommandLineBuilder RegisterWithDotnetSuggest()
74
+
public CommandLineBuilder UseDefaults()
75
+
public CommandLineBuilder UseEnvironmentVariableDirective()
76
+
public CommandLineBuilder UseExceptionHandler(System.Action<System.Exception,System.CommandLine.Invocation.InvocationContext> onException = null, System.Nullable<System.Int32> errorExitCode = null)
77
+
public CommandLineBuilder UseHelp(System.Nullable<System.Int32> maxWidth = null)
78
+
public CommandLineBuilder UseHelp(System.String[] helpAliases)
79
+
public CommandLineBuilder UseHelp(System.Action<System.CommandLine.Help.HelpContext> customize, System.Nullable<System.Int32> maxWidth = null)
80
+
public CommandLineBuilder UseHelpBuilder(System.Func<System.CommandLine.Binding.BindingContext,System.CommandLine.Help.HelpBuilder> getHelpBuilder)
81
+
public CommandLineBuilder UseParseDirective(System.Int32 errorExitCode = 1)
82
+
public CommandLineBuilder UseParseErrorReporting(System.Int32 errorExitCode = 1)
83
+
public CommandLineBuilder UseSuggestDirective()
84
+
public CommandLineBuilder UseTokenReplacer(System.CommandLine.Parsing.TryReplaceToken replaceToken)
85
+
public CommandLineBuilder UseTypoCorrections(System.Int32 maxLevenshteinDistance = 3)
86
+
public CommandLineBuilder UseVersionOption()
87
+
public CommandLineBuilder UseVersionOption(System.String[] aliases)
91
88
public class CommandLineConfiguration
89
+
public static CommandLineBuilder CreateBuilder(Command rootCommand)
public class CommandLineConfigurationException : System.Exception, System.Runtime.Serialization.ISerializable
99
101
.ctor(System.String message)
@@ -149,8 +151,6 @@ System.CommandLine
149
151
public System.Collections.Generic.List<System.Action<System.CommandLine.Parsing.OptionResult>> Validators { get; }
150
152
public System.Type ValueType { get; }
151
153
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.CommandLine.Completions.CompletionContext context)
152
-
public ParseResult Parse(System.String commandLine)
153
-
public ParseResult Parse(System.String[] args)
154
154
public class Option<T> : Option, IValueDescriptor<T>, System.CommandLine.Binding.IValueDescriptor
public static Option<T> AcceptExistingOnly<T>(this Option<T> option)
171
171
public class ParseResult
172
172
public System.CommandLine.Parsing.CommandResult CommandResult { get; }
173
+
public CommandLineConfiguration Configuration { get; }
173
174
public System.Collections.Generic.IReadOnlyDictionary<System.String,System.Collections.Generic.IReadOnlyList<System.String>> Directives { get; }
174
175
public System.Collections.Generic.IReadOnlyList<System.CommandLine.Parsing.ParseError> Errors { get; }
175
-
public System.CommandLine.Parsing.Parser Parser { get; }
176
176
public System.CommandLine.Parsing.CommandResult RootCommandResult { get; }
177
177
public System.Collections.Generic.IReadOnlyList<System.CommandLine.Parsing.Token> Tokens { get; }
178
178
public System.Collections.Generic.IReadOnlyList<System.String> UnmatchedTokens { get; }
@@ -184,6 +184,8 @@ System.CommandLine
184
184
public System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem> GetCompletions(System.Nullable<System.Int32> position = null)
185
185
public T GetValue<T>(Argument<T> argument)
186
186
public T GetValue<T>(Option<T> option)
187
+
public System.Int32 Invoke(IConsole console = null)
188
+
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(IConsole console = null, System.Threading.CancellationToken cancellationToken = null)
187
189
public System.String ToString()
188
190
public class RootCommand : Command, System.Collections.Generic.IEnumerable<Symbol>, System.Collections.IEnumerable
189
191
public static System.String ExecutableName { get; }
@@ -286,7 +288,6 @@ System.CommandLine.Invocation
286
288
public System.Int32 ExitCode { get; set; }
287
289
public System.CommandLine.Help.HelpBuilder HelpBuilder { get; }
288
290
public System.Action<InvocationContext> InvocationResult { get; set; }
289
-
public System.CommandLine.Parsing.Parser Parser { get; }
290
291
public System.CommandLine.ParseResult ParseResult { get; set; }
0 commit comments