From the architecture review, "Construction, start and stop", under "Commands are dispatched by hand": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next. Line numbers are that commit's.
What is there
sww.Main (internal/sww/sww.go:56) switches on os.Args[1] and prints a usage text kept by hand (usage, line 30).
HealthCheck (internal/sww/healthcheck.go:35) rejects arguments by hand.
Why it matters
GO_PACKAGE_DEFAULTS.md names github.com/spf13/cobra as the decided default for CLI commands.
The review rated this the smallest gain of its proposals: three commands and no flags. It is here because the default is decided, not because the switch is hard to follow.
What changes
Three cobra commands in internal/sww: rproxy, waf and healthcheck. Each calls what Main calls today: RunRProxy, RunWAF, HealthCheck.
cmd/sww/main.go stays one call, and sww.Main(version) int stays the entry the tests call.
The hand-kept usage text goes: cobra prints the commands from their own descriptions.
What stays
Exit statuses:
2 with no command, or one sww does not know;
what RunRProxy, RunWAF and HealthCheck return, for theirs.
sww healthcheck with an argument, such as now, still writes sww healthcheck: unexpected argument "now" to stderr and returns 1, without checking anything.
A daemon's stdout carries JSON lines only. cobra prints nothing there, and prints no usage after a daemon fails to start or stops with an error.
cobra's completion command is turned off.
The image's HEALTHCHECK and share/sww.run call the same commands with the same arguments.
What a user can see change
The wording of the usage text, which cobra now writes.
sww --help and sww help print the commands and exit 0. Today both are unknown commands and exit 2.
Done when
sww.Main holds no switch on the command, and internal/sww holds no usage text of its own;
SPEC's "Architecture" lists cobra among the libraries;
every existing test passes; an assertion changes only where it quotes the old usage text;
make check passes.
If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
From the architecture review, "Construction, start and stop", under "Commands are dispatched by hand": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173831. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`. Line numbers are that commit's.
### What is there
- `sww.Main` (`internal/sww/sww.go:56`) switches on `os.Args[1]` and prints a usage text kept by hand (`usage`, line 30).
- `HealthCheck` (`internal/sww/healthcheck.go:35`) rejects arguments by hand.
### Why it matters
- `GO_PACKAGE_DEFAULTS.md` names `github.com/spf13/cobra` as the decided default for CLI commands.
- The review rated this the smallest gain of its proposals: three commands and no flags. It is here because the default is decided, not because the switch is hard to follow.
### What changes
- Three `cobra` commands in `internal/sww`: `rproxy`, `waf` and `healthcheck`. Each calls what `Main` calls today: `RunRProxy`, `RunWAF`, `HealthCheck`.
- `cmd/sww/main.go` stays one call, and `sww.Main(version) int` stays the entry the tests call.
- The hand-kept usage text goes: `cobra` prints the commands from their own descriptions.
### What stays
- Exit statuses:
- 2 with no command, or one sww does not know;
- what `RunRProxy`, `RunWAF` and `HealthCheck` return, for theirs.
- `sww healthcheck` with an argument, such as `now`, still writes `sww healthcheck: unexpected argument "now"` to stderr and returns 1, without checking anything.
- A daemon's stdout carries JSON lines only. `cobra` prints nothing there, and prints no usage after a daemon fails to start or stops with an error.
- `cobra`'s completion command is turned off.
- The image's `HEALTHCHECK` and `share/sww.run` call the same commands with the same arguments.
### What a user can see change
- The wording of the usage text, which `cobra` now writes.
- `sww --help` and `sww help` print the commands and exit 0. Today both are unknown commands and exit 2.
### Done when
- `sww.Main` holds no `switch` on the command, and `internal/sww` holds no usage text of its own;
- SPEC's "Architecture" lists `cobra` among the libraries;
- every existing test passes; an assertion changes only where it quotes the old usage text;
- `make check` passes.
If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
clawbot
self-assigned this 2026-11-19 17:13:13 +01:00
sww.Main runs a cobra root command with rproxy, waf and healthcheck under it; the switch and the hand-kept usage text are gone. Exit statuses and sww healthcheck now behave as before. sww help and sww --help exit 0. SPEC lists cobra.
Judgement call: sww healthcheck --x is now cobra's unknown-flag error, exit 2, instead of an unexpected argument, exit 1.
Model: opus-5-5
PR: https://git.eeqj.de/sneak/smallwebwaf/pulls/460, branch `issue-440-cobra-commands`.
`sww.Main` runs a `cobra` root command with `rproxy`, `waf` and `healthcheck` under it; the switch and the hand-kept usage text are gone. Exit statuses and `sww healthcheck now` behave as before. `sww help` and `sww --help` exit 0. SPEC lists `cobra`.
Judgement call: `sww healthcheck --x` is now `cobra`'s unknown-flag error, exit 2, instead of an unexpected argument, exit 1.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
From the architecture review, "Construction, start and stop", under "Commands are dispatched by hand": #283 (comment). Approved for building: #283 (comment). The code was read at
809d266onnext. Line numbers are that commit's.What is there
sww.Main(internal/sww/sww.go:56) switches onos.Args[1]and prints a usage text kept by hand (usage, line 30).HealthCheck(internal/sww/healthcheck.go:35) rejects arguments by hand.Why it matters
GO_PACKAGE_DEFAULTS.mdnamesgithub.com/spf13/cobraas the decided default for CLI commands.What changes
cobracommands ininternal/sww:rproxy,wafandhealthcheck. Each calls whatMaincalls today:RunRProxy,RunWAF,HealthCheck.cmd/sww/main.gostays one call, andsww.Main(version) intstays the entry the tests call.cobraprints the commands from their own descriptions.What stays
RunRProxy,RunWAFandHealthCheckreturn, for theirs.sww healthcheckwith an argument, such asnow, still writessww healthcheck: unexpected argument "now"to stderr and returns 1, without checking anything.cobraprints nothing there, and prints no usage after a daemon fails to start or stops with an error.cobra's completion command is turned off.HEALTHCHECKandshare/sww.runcall the same commands with the same arguments.What a user can see change
cobranow writes.sww --helpandsww helpprint the commands and exit 0. Today both are unknown commands and exit 2.Done when
sww.Mainholds noswitchon the command, andinternal/swwholds no usage text of its own;cobraamong the libraries;make checkpasses.If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
PR: #460, branch
issue-440-cobra-commands.sww.Mainruns acobraroot command withrproxy,wafandhealthcheckunder it; the switch and the hand-kept usage text are gone. Exit statuses andsww healthcheck nowbehave as before.sww helpandsww --helpexit 0. SPEC listscobra.Judgement call:
sww healthcheck --xis nowcobra's unknown-flag error, exit 2, instead of an unexpected argument, exit 1.Model: opus-5-5