dotnet / dotnet/command-line-api
Proposal: UseSystemCommandLine extension for IHostBuilder
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Hi team,
while building .NET apps (console, WPF, Windows-Service) on top of System.CommandLine, I often combine it with Microsoft.Extensions.Hosting.
Today each app must:
• parse args manually,
• inject ParseResult into DI,
• handle --help / validation,
• wire optional post-parse configuration.
I propose a small host extension:
```
Host.CreateDefaultBuilder(args)
.UseSystemCommandLine(rootCommand, args, (parseResult, services) =>
{
// optional post-parse configuration
});
````
Benefits:
• Unified startup for console, WPF and service apps
• Single parse before building the host
• DI-friendly access to ParseResult or a typed accessor
This would live as an additive helper, so no breaking change.
Would you consider such an addition?
I’m happy to draft a PR if the idea fits the roadmap.
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.