netwatch-server starts the server when given arguments it does not understand #179

Closed
opened 2026-10-19 06:22:46 +02:00 by clawbot · 1 comment
Collaborator

netwatch-server starts the server whenever its arguments are not exactly one of its two subcommand forms (cmd/netwatch-server/main.go on next; internal/cli/cli.go once #178 is merged). So netwatch-server check-cidr with no value, netwatch-server prepare-data-dir with two values, or a misspelt netwatch-server check-cdir 10.0.0.0/8 start the whole server, which then holds the port, instead of refusing the command line.

How to see it: netwatch-server check-cidr (no value) in the image: it logs its startup lines and listens, and exits only on a signal.

What is right: a command line the program does not understand is refused with a short usage message on stderr and a non-zero exit, as the two subcommands already refuse a bad value; only no arguments at all starts the server. Found while moving the dispatch for #160.

Severity: low. bin/entrypoint.sh always passes the right arguments.

Definition of done

  • With no arguments the server starts as now; check-cidr CIDR and prepare-data-dir DATA_DIR behave as now; any other arguments print a one-line usage message naming both forms to stderr and exit 2 without starting anything.
  • Tests cover a subcommand with too few and too many values and an unknown first argument.
  • README.md says how to run the two subcommands only if it already describes them; TODO.md updated in the same commit; commit title ends (closes #N) with this issue's number.

Model: opus-5-5

`netwatch-server` starts the server whenever its arguments are not exactly one of its two subcommand forms (`cmd/netwatch-server/main.go` on `next`; `internal/cli/cli.go` once https://git.eeqj.de/sneak/netwatch/pulls/178 is merged). So `netwatch-server check-cidr` with no value, `netwatch-server prepare-data-dir` with two values, or a misspelt `netwatch-server check-cdir 10.0.0.0/8` start the whole server, which then holds the port, instead of refusing the command line. **How to see it**: `netwatch-server check-cidr` (no value) in the image: it logs its startup lines and listens, and exits only on a signal. **What is right**: a command line the program does not understand is refused with a short usage message on stderr and a non-zero exit, as the two subcommands already refuse a bad value; only no arguments at all starts the server. Found while moving the dispatch for https://git.eeqj.de/sneak/netwatch/issues/160. **Severity**: low. `bin/entrypoint.sh` always passes the right arguments. ## Definition of done - [ ] With no arguments the server starts as now; `check-cidr CIDR` and `prepare-data-dir DATA_DIR` behave as now; any other arguments print a one-line usage message naming both forms to stderr and exit 2 without starting anything. - [ ] Tests cover a subcommand with too few and too many values and an unknown first argument. - [ ] `README.md` says how to run the two subcommands only if it already describes them; `TODO.md` updated in the same commit; commit title ends ` (closes #N)` with this issue's number. Model: opus-5-5
clawbot self-assigned this 2026-10-19 06:22:46 +02:00
Author
Collaborator

Built in #187: any command line other than no arguments, check-cidr CIDR or prepare-data-dir DATA_DIR now gets a one-line usage message on stderr and exit code 2.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/netwatch/pulls/187: any command line other than no arguments, `check-cidr CIDR` or `prepare-data-dir DATA_DIR` now gets a one-line usage message on stderr and exit code 2. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/netwatch#179