sww: the three commands as cobra commands (closes #440) #460

Open
clawbot wants to merge 2 commits from issue-440-cobra-commands into next
pull from: issue-440-cobra-commands
Collaborator

Closes #440

sww.Main now builds a cobra root command with rproxy, waf and healthcheck under it. The switch on os.Args and the hand-kept usage text are gone; cobra prints the commands from their Short descriptions.

  • Each command's Run stores what RunRProxy, RunWAF or HealthCheck returns, and Main returns that. The commands use Run, not RunE, so cobra prints nothing after a daemon fails.
  • The root command has Args: cobra.NoArgs and a RunE that returns "no command given". Without them, cobra prints help to stdout and exits 0 for no command. It also prints no command list for an unknown one. Any error from cobra makes Main return 2.
  • cobra's completion command is off.
  • The healthcheck command has DisableFlagParsing, so HealthCheck still checks every argument itself, flags included: sww healthcheck now, --x or -h writes the same message and returns 1.
  • SPEC's "Architecture" lists cobra and says sww help and sww --help exit 0.

Tests: help, --help, completion, and healthcheck with now, --x or -h, run through Main in a process of its own.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/440 `sww.Main` now builds a `cobra` root command with `rproxy`, `waf` and `healthcheck` under it. The switch on `os.Args` and the hand-kept usage text are gone; `cobra` prints the commands from their `Short` descriptions. - Each command's `Run` stores what `RunRProxy`, `RunWAF` or `HealthCheck` returns, and `Main` returns that. The commands use `Run`, not `RunE`, so `cobra` prints nothing after a daemon fails. - The root command has `Args: cobra.NoArgs` and a `RunE` that returns "no command given". Without them, `cobra` prints help to stdout and exits 0 for no command. It also prints no command list for an unknown one. Any error from `cobra` makes `Main` return 2. - `cobra`'s completion command is off. - The `healthcheck` command has `DisableFlagParsing`, so `HealthCheck` still checks every argument itself, flags included: `sww healthcheck now`, `--x` or `-h` writes the same message and returns 1. - SPEC's "Architecture" lists `cobra` and says `sww help` and `sww --help` exit 0. Tests: `help`, `--help`, `completion`, and `healthcheck` with `now`, `--x` or `-h`, run through `Main` in a process of its own. Model: opus-5-5
clawbot added 1 commit 2026-11-19 17:44:55 +01:00
Main builds a cobra root command with rproxy, waf and healthcheck under
it, in place of the switch on os.Args and the hand-kept usage text.
Exit statuses stay: 2 with no command or an unknown one, otherwise what
the command returns. cobra's completion command is off. `sww help` and
`sww --help` now print the commands and exit 0.

Model: opus-5-5
clawbot self-assigned this 2026-11-19 17:44:57 +01:00
clawbot added the needs-review label 2026-11-19 17:44:58 +01:00
clawbot added 1 commit 2026-11-19 18:02:20 +01:00
sww: healthcheck refuses flag arguments itself
check / check (push) Waiting to run
d17f72d1ef
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
Author
Collaborator

Verdict: FAIL
Head: 504515c1d1

  1. internal/sww/sww.go, the healthcheck command: cobra parsed its flags, so sww healthcheck --x exited 2 with cobra's error and sww healthcheck -h printed help and exited 0. The issue keeps HealthCheck's own message and status 1 for any argument. Fixed on the branch in d17f72d1ef (DisableFlagParsing, with tests); nothing is left for a rework, and the new head needs its own review.
  • Disclosure: the PR body's judgement-call paragraph described the old behaviour; I updated the body to match the fix.
  • Judgement call: sww waf --help and sww rproxy --help now print help instead of starting the daemon; taken as part of the help the issue grants, not a finding.

Model: opus-5-5

Verdict: FAIL Head: 504515c1d102801840b1df56c87654e4b785a331 1. `internal/sww/sww.go`, the `healthcheck` command: `cobra` parsed its flags, so `sww healthcheck --x` exited 2 with `cobra`'s error and `sww healthcheck -h` printed help and exited 0. The issue keeps `HealthCheck`'s own message and status 1 for any argument. Fixed on the branch in https://git.eeqj.de/sneak/smallwebwaf/commit/d17f72d1ef2d2b8d095f153737edd6571a75d03e (`DisableFlagParsing`, with tests); nothing is left for a rework, and the new head needs its own review. - Disclosure: the PR body's judgement-call paragraph described the old behaviour; I updated the body to match the fix. - Judgement call: `sww waf --help` and `sww rproxy --help` now print help instead of starting the daemon; taken as part of the help the issue grants, not a finding. Model: opus-5-5
Author
Collaborator

Verdict: PASS
Head: d17f72d1ef

sww now runs its three commands through cobra and keeps the exit statuses, the healthcheck argument message and the quiet daemon stdout the issue requires.

  • Judgement call: cobra's hidden __complete command still answers, with exit status 0; cobra has no switch to turn it off, and it is not a command sww lists, so it is not counted as a finding.

Model: opus-5-5

Verdict: PASS Head: d17f72d1ef2d2b8d095f153737edd6571a75d03e `sww` now runs its three commands through `cobra` and keeps the exit statuses, the `healthcheck` argument message and the quiet daemon stdout the issue requires. - Judgement call: `cobra`'s hidden `__complete` command still answers, with exit status 0; `cobra` has no switch to turn it off, and it is not a command `sww` lists, so it is not counted as a finding. Model: opus-5-5
Some checks are pending
check / check (push) Waiting to run
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-440-cobra-commands:issue-440-cobra-commands
git checkout issue-440-cobra-commands
Sign in to join this conversation.