sww: healthcheck refuses flag arguments itself
check / check (push) Successful in 6m10s

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
This commit is contained in:
sneak committed 2026-11-19 17:02:15 +00:00
1 parent 504515c1d1
commit d17f72d1ef
2 files changed
+11 -2

No files matched your search

+2
View File
@@ -89,6 +89,8 @@ func Main(version string) int {
&cobra.Command{ &cobra.Command{
Use: "healthcheck", Use: "healthcheck",
Short: "the container's health check", Short: "the container's health check",
// HealthCheck refuses every argument itself, flags included.
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
status = HealthCheck( status = HealthCheck(
cmd.Context(), cmd.Context(),
+9 -2
View File
@@ -218,13 +218,20 @@ func wantTheCommands(t *testing.T, where, text string) {
func TestMainHealthCheckRefusesAnArgument(t *testing.T) { func TestMainHealthCheckRefusesAnArgument(t *testing.T) {
t.Parallel() 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" code, stdout, stderr := runMain(t, "healthcheck "+argument)
want := "sww healthcheck: unexpected argument \"" +
argument + "\"\n"
if code != 1 || stderr != want || stdout != "" { if code != 1 || stderr != want || stdout != "" {
t.Errorf("exit status %d, stdout %q and stderr %q, "+ t.Errorf("exit status %d, stdout %q and stderr %q, "+
"want 1, nothing and %q", code, stdout, stderr, want) "want 1, nothing and %q", code, stdout, stderr, want)
} }
})
}
} }
// runMain runs Main with command in a process of its own, and returns its // runMain runs Main with command in a process of its own, and returns its