From d17f72d1ef2d2b8d095f153737edd6571a75d03e Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 19 Nov 2026 17:02:15 +0000 Subject: [PATCH] sww: healthcheck refuses flag arguments itself cobra parsed flags for `sww healthcheck`, so `--x` exited 2 with cobra's error and `-h` printed help and exited 0, where the issue keeps HealthCheck's own message and status 1 for any argument. The command now passes every argument to HealthCheck. Model: opus-5-5 --- internal/sww/sww.go | 2 ++ internal/sww/waf_test.go | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/sww/sww.go b/internal/sww/sww.go index e2a434f..e70f73f 100644 --- a/internal/sww/sww.go +++ b/internal/sww/sww.go @@ -89,6 +89,8 @@ func Main(version string) int { &cobra.Command{ Use: "healthcheck", Short: "the container's health check", + // HealthCheck refuses every argument itself, flags included. + DisableFlagParsing: true, Run: func(cmd *cobra.Command, args []string) { status = HealthCheck( cmd.Context(), diff --git a/internal/sww/waf_test.go b/internal/sww/waf_test.go index 271b33e..340e84c 100644 --- a/internal/sww/waf_test.go +++ b/internal/sww/waf_test.go @@ -218,12 +218,19 @@ func wantTheCommands(t *testing.T, where, text string) { func TestMainHealthCheckRefusesAnArgument(t *testing.T) { t.Parallel() - code, stdout, stderr := runMain(t, "healthcheck now") + for _, argument := range []string{"now", "--x", "-h"} { + t.Run("argument "+argument, func(t *testing.T) { + t.Parallel() - want := "sww healthcheck: unexpected argument \"now\"\n" - if code != 1 || stderr != want || stdout != "" { - t.Errorf("exit status %d, stdout %q and stderr %q, "+ - "want 1, nothing and %q", code, stdout, stderr, want) + code, stdout, stderr := runMain(t, "healthcheck "+argument) + + want := "sww healthcheck: unexpected argument \"" + + argument + "\"\n" + if code != 1 || stderr != want || stdout != "" { + t.Errorf("exit status %d, stdout %q and stderr %q, "+ + "want 1, nothing and %q", code, stdout, stderr, want) + } + }) } }