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
Update System.CommandLine docs to 2.0.0-beta7 (dotnet#48180)
* bump System.CommandLine to beta7 to ensure they can be compiled with the latest version that will have no breaking changes with the upcoming RTM release
* check for errors before calling GetValue, as it may throw when there are errors
* update the docs to beta7
Copy file name to clipboardExpand all lines: docs/standard/commandline/how-to-configure-the-parser.md
+21-14Lines changed: 21 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,26 @@ ms.topic: how-to
14
14
15
15
[!INCLUDE [scl-preview](./includes/preview.md)]
16
16
17
-
<xref:System.CommandLine.ParserConfiguration> is a class that provides properties to configure the parser. It is an optional argument for every `Parse` method, such as <xref:System.CommandLine.Command.Parse*?displayProperty=nameWithType> and <xref:System.CommandLine.Parsing.CommandLineParser.Parse*?displayProperty=nameWithType>. When it isn't provided, the default configuration is used.
17
+
Parsing and invocation are two separate steps, so each of them has their own configuration:
18
18
19
-
<xref:System.CommandLine.ParseResult> has a <xref:System.CommandLine.ParseResult.Configuration> property that returns the configuration used for parsing.
19
+
-<xref:System.CommandLine.ParserConfiguration> is a class that provides properties to configure the parsing. It is an optional argument for every `Parse` method, such as <xref:System.CommandLine.Command.Parse*?displayProperty=nameWithType> and <xref:System.CommandLine.Parsing.CommandLineParser.Parse*?displayProperty=nameWithType>.
20
+
-<xref:System.CommandLine.InvocationConfiguration> is a class that provides properties to configure the invocation. It is an optional argument of the <xref:System.CommandLine.ParseResult.Invoke*?displayProperty=nameWithType> and <xref:System.CommandLine.ParseResult.InvokeAsync*?displayProperty=nameWithType> methods.
20
21
21
-
## Standard output and error
22
+
They are exposed by the <xref:System.CommandLine.ParseResult.Configuration?displayProperty=nameWithType> and <xref:System.CommandLine.ParseResult.InvocationConfiguration?displayProperty=nameWithType> properties. When they aren't provided, the default configurations are used.
23
+
24
+
## ParserConfiguration
25
+
26
+
### EnablePosixBundling
27
+
28
+
[Bundling](syntax.md#option-bundling) of single-character options is enabled by default, but you can disable it by setting the <xref:System.CommandLine.ParserConfiguration.EnablePosixBundling?displayProperty=nameWithType> property to `false`.
29
+
30
+
### ResponseFileTokenReplacer
31
+
32
+
[Response files](syntax.md#response-files) are enabled by default, but you can disable them by setting the <xref:System.CommandLine.ParserConfiguration.ResponseFileTokenReplacer> property to `null`. You can also provide a custom implementation to customize how response files are processed.
33
+
34
+
## InvocationConfiguration
35
+
36
+
### Standard output and error
22
37
23
38
<xref:System.CommandLine.InvocationConfiguration> makes testing, as well as many extensibility scenarios, easier than using `System.Console`. It exposes two `TextWriter` properties: <xref:System.CommandLine.InvocationConfiguration.Output> and <xref:System.CommandLine.InvocationConfiguration.Error>. You can set these properties to any `TextWriter` instance, such as a `StringWriter`, which you can use to capture output for testing.
24
39
@@ -30,23 +45,15 @@ Now, use <xref:System.CommandLine.InvocationConfiguration> to capture the output
[Bundling](syntax.md#option-bundling) of single-character options is enabled by default, but you can disable it by setting the <xref:System.CommandLine.ParserConfiguration.EnablePosixBundling?displayProperty=nameWithType> property to `false`.
36
-
37
-
## ProcessTerminationTimeout
48
+
### ProcessTerminationTimeout
38
49
39
50
[Process termination timeout](how-to-parse-and-invoke.md#process-termination-timeout) can be configured via the <xref:System.CommandLine.InvocationConfiguration.ProcessTerminationTimeout> property. The default value is 2 seconds.
40
51
41
-
## ResponseFileTokenReplacer
42
-
43
-
[Response files](syntax.md#response-files) are enabled by default, but you can disable them by setting the <xref:System.CommandLine.ParserConfiguration.ResponseFileTokenReplacer> property to `null`. You can also provide a custom implementation to customize how response files are processed.
44
-
45
-
## EnableDefaultExceptionHandler
52
+
### EnableDefaultExceptionHandler
46
53
47
54
By default, all unhandled exceptions thrown during the invocation of a command are caught and reported to the user. You can disable this behavior by setting the <xref:System.CommandLine.InvocationConfiguration.EnableDefaultExceptionHandler> property to `false`. This is useful when you want to handle exceptions in a custom way, such as logging them or providing a different user experience.
48
55
49
-
## Derived classes
56
+
###Derived classes
50
57
51
58
<xref:System.CommandLine.InvocationConfiguration> is not sealed, so you can derive from it to add custom properties or methods. This is useful when you want to provide additional configuration options specific to your application.
Copy file name to clipboardExpand all lines: docs/standard/commandline/includes/preview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,5 +3,5 @@ ms.date: 07/31/2025
3
3
ms.topic: include
4
4
---
5
5
> [!IMPORTANT]
6
-
> `System.CommandLine` is currently in preview. This documentation is for version 2.0 beta 5.
6
+
> `System.CommandLine` is currently in preview. This documentation is for version 2.0 beta 7.
7
7
> Some information relates to prerelease product that might be substantially modified before it's released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
0 commit comments