Summary
Add System.CommandLine Option for .NET CLI Schema via --cli-schema.
Remarks
The .NET CLI added CLI introspection with --cli-schema in the .NET 10 SDK.
Features
- Add a public API that adds an
Option<bool> to System.CommandLine applications
Option<bool> should be recursive, to allow to JSONify the CLI command tree for the invoked command or subcommand
Option<bool> should be hidden, to not show in the help output
- Might accept optional JSON-Serializer options
- If there is a difference in the format of the output between .NET 10 and the upcoming .NET 11
- then add a (required/optional) parameter as an
enum to select the version
- Should be Trim-friendly and AOT-compatible, or have an overload that is
- Use
System.Text.Json to output the JSON representation
- target frameworks without built-in support as part of the shared framework should use the System.Text.Json NuGet package
- Use StringSyntaxAttribute.Json for testing
- Add Benchmarks for relevant
public members
- Set appropriate
<TargetFrameworks> for the Library
- use multi-targeting for the Test project
- Ensure to be callable/invocable from
C#, F#, and Visual Basic
Example
See: https://learn.microsoft.com/dotnet/core/whats-new/dotnet-10/sdk#cli-introspection-with---cli-schema
See also
Summary
Add
System.CommandLineOption for .NET CLI Schema via--cli-schema.Remarks
The .NET CLI added CLI introspection with
--cli-schemain the .NET 10 SDK.Features
Option<bool>toSystem.CommandLineapplicationsOption<bool>should be recursive, to allow to JSONify the CLI command tree for the invoked command or subcommandOption<bool>should be hidden, to not show in the help outputenumto select the versionSystem.Text.Jsonto output the JSON representationpublicmembers<TargetFrameworks>for the LibraryC#,F#, andVisual BasicExample
See: https://learn.microsoft.com/dotnet/core/whats-new/dotnet-10/sdk#cli-introspection-with---cli-schema
See also
System.CommandLinerepository: https://github.com/dotnet/command-line-apiSystem.CommandLinedocumentation: https://learn.microsoft.com/dotnet/standard/commandline/System.Text.Jsondocumentation: https://learn.microsoft.com/dotnet/standard/serialization/system-text-json/overview