Skip to content

Commit 358b285

Browse files
authored
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
1 parent cc97374 commit 358b285

File tree

12 files changed

+32
-25
lines changed

12 files changed

+32
-25
lines changed

docs/standard/commandline/how-to-configure-the-parser.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,26 @@ ms.topic: how-to
1414

1515
[!INCLUDE [scl-preview](./includes/preview.md)]
1616

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:
1818

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.
2021

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
2237

2338
<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.
2439

@@ -30,23 +45,15 @@ Now, use <xref:System.CommandLine.InvocationConfiguration> to capture the output
3045

3146
:::code language="csharp" source="snippets/configuration/csharp/Program.cs" id="captureoutput":::
3247

33-
## EnablePosixBundling
34-
35-
[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
3849

3950
[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.
4051

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
4653

4754
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.
4855

49-
## Derived classes
56+
### Derived classes
5057

5158
<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.
5259

docs/standard/commandline/includes/preview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ ms.date: 07/31/2025
33
ms.topic: include
44
---
55
> [!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.
77
> 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.

docs/standard/commandline/snippets/customize-help/csharp/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
1313
<PackageReference Include="Spectre.Console" Version="0.48.0" />
14-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
14+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1515
</ItemGroup>
1616

1717
</Project>

docs/standard/commandline/snippets/define-symbols/csharp/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
11+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1212
</ItemGroup>
1313

1414
</Project>

docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage0/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static int Main(string[] args)
2020

2121
// <parse>
2222
ParseResult parseResult = rootCommand.Parse(args);
23-
if (parseResult.GetValue(fileOption) is FileInfo parsedFile)
23+
if (parseResult.Errors.Count == 0 && parseResult.GetValue(fileOption) is FileInfo parsedFile)
2424
{
2525
ReadFile(parsedFile);
2626
return 0;

docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage0/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
11+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1212
</ItemGroup>
1313

1414
</Project>

docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage1/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
11+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage2/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
17+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1818
</ItemGroup>
1919

2020
</Project>

docs/standard/commandline/snippets/get-started-tutorial/csharp/Stage3/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
11+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

docs/standard/commandline/snippets/handle-termination/csharp/scl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25277.114" />
11+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta7.25380.108" />
1212
</ItemGroup>
1313

1414
</Project>

0 commit comments

Comments
 (0)