dotnet / dotnet/command-line-api
UseCommandHandler not works with UseParseErrorReporting
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Use codes from test
https://github.com/dotnet/command-line-api/blob/34a2df49f1dcf3fdc46d0c4a3daedf84b3057e05/src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs#L22-L42
but add `UseParseErrorReporting` like this:
```cs
[Fact]
public static async Task Constructor_Injection_Injects_Service()
{
var service = new MyService();
var parser = new CommandLineBuilder(
new MyCommand()
)
.UseHost((builder) => {
builder.ConfigureServices(services =>
{
services.AddTransient(x => service);
})
.UseCommandHandler();
})
.UseParseErrorReporting()
.Build();
var result = await parser.InvokeAsync(new string[] { "--int-option", "54"});
service.Value.Should().Be(54);
}
```
It will report `Required command was not provided.` when parsing.
Contributor guide
Assessment
This issue has not been assessed yet.