Route help and version through the reporter

This commit is contained in:
2026-10-26 03:02:08 +00:00
parent 49a10690c6
commit 7a1067d387
5 changed files with 146 additions and 83 deletions

View File

@@ -36,7 +36,7 @@ func TestDiscoveryUsageRetainsEnteredPrefix(t *testing.T) {
t.Run(prefix+"/"+test.name, func(t *testing.T) {
var output, diagnostics bytes.Buffer
outcome := app.Execute(context.Background(), append(strings.Fields(prefix), test.tail...), Streams{Out: &output, Err: &diagnostics})
if outcome.Kind != OutcomeUsage || outcome.Status != 2 || outcome.DiagnosticDelivery != DeliveryComplete || output.Len() != 0 {
if outcome.Kind != OutcomeUsage || outcome.Status != 2 || outcome.Presentation.Diagnostics.State != DeliveryComplete || output.Len() != 0 {
t.Fatalf("outcome = %#v, output %q", outcome, output.String())
}
for _, fragment := range []string{test.want, "Usage: Demo " + prefix} {
@@ -828,7 +828,7 @@ func TestAliasUsageSurvivesRegistrationDuringExecution(t *testing.T) {
Name: "inspect",
Run: func(Invocation, struct{}) Outcome {
registrationErr = test.register(app)
return Usage(errors.New("operation rejected"))
return Usage("operation rejected").WithCause(errors.New("operation rejected"))
},
})
var err error