netwatch-server refuses arguments it does not understand (closes #179) #187

Merged
clawbot merged 1 commits from issue-179-refuse-unknown-args into next 2026-10-19 08:09:14 +02:00
Collaborator

netwatch-server now starts the server only when given no arguments (#179). check-cidr CIDR and prepare-data-dir DATA_DIR behave as before. Any other command line, such as a subcommand with no value or two values, or a misspelt subcommand, gets this line on stderr and exit code 2, and nothing starts:

usage: netwatch-server [check-cidr CIDR | prepare-data-dir DATA_DIR]

It used to start the server, which then held the port.

The change is in cli.Main in internal/cli, whose doc comment covers the command line. That doc comment and the cli line in README.md said the package runs the server "otherwise"; they now say it does so given no arguments. README.md does not describe how to run the subcommands, so it gets no usage section.

What the diff does not show:

  • The refused cases in TestMainRefusesOtherCommandLines are whole command lines split on spaces, program name dropped. Written as lists of arguments they repeated check-cidr often enough for the linter to ask for a constant.
  • bin/entrypoint.sh always passes check-cidr exactly one quoted, non-empty value, so it never gets the new usage refusal.

Judgement call: netwatch-server --help is refused like any other unknown argument, with the usage line and exit code 2.

Model: opus-5-5

`netwatch-server` now starts the server only when given no arguments (https://git.eeqj.de/sneak/netwatch/issues/179). `check-cidr CIDR` and `prepare-data-dir DATA_DIR` behave as before. Any other command line, such as a subcommand with no value or two values, or a misspelt subcommand, gets this line on stderr and exit code 2, and nothing starts: usage: netwatch-server [check-cidr CIDR | prepare-data-dir DATA_DIR] It used to start the server, which then held the port. The change is in `cli.Main` in `internal/cli`, whose doc comment covers the command line. That doc comment and the `cli` line in `README.md` said the package runs the server "otherwise"; they now say it does so given no arguments. `README.md` does not describe how to run the subcommands, so it gets no usage section. What the diff does not show: - The refused cases in `TestMainRefusesOtherCommandLines` are whole command lines split on spaces, program name dropped. Written as lists of arguments they repeated `check-cidr` often enough for the linter to ask for a constant. - `bin/entrypoint.sh` always passes `check-cidr` exactly one quoted, non-empty value, so it never gets the new usage refusal. Judgement call: `netwatch-server --help` is refused like any other unknown argument, with the usage line and exit code 2. Model: opus-5-5
clawbot added the needs-review label 2026-10-19 08:00:56 +02:00
clawbot self-assigned this 2026-10-19 08:00:56 +02:00
clawbot added 1 commit 2026-10-19 08:00:56 +02:00
cli.Main starts the server only when given no arguments. check-cidr
CIDR and prepare-data-dir DATA_DIR run as before. Any other command
line, such as a subcommand with no value or two values, or a misspelt
subcommand, gets a one-line usage message naming both forms on stderr
and exit code 2. It used to start the server, which then held the
port.

Model: opus-5-5
Author
Collaborator
  1. PR body, second bullet under "What the diff does not show": the claim that an empty TRUSTED_PROXIES entry "is still two arguments and still reaches check-cidr" is not what bin/entrypoint.sh does. In write_trusted_proxies (lines 56-62), the unquoted $(... | tr ',' ' ') is split by the shell, which drops empty entries before the loop, so an empty entry never reaches check-cidr. Every value that does reach it is a non-empty CIDR, passed quoted. Acceptable: drop the bullet, or replace it with what the script does: it always passes check-cidr exactly one quoted, non-empty value, so it never gets the new usage refusal.

Model: opus-5-5

1. PR body, second bullet under "What the diff does not show": the claim that an empty `TRUSTED_PROXIES` entry "is still two arguments and still reaches `check-cidr`" is not what `bin/entrypoint.sh` does. In `write_trusted_proxies` (lines 56-62), the unquoted `$(... | tr ',' ' ')` is split by the shell, which drops empty entries before the loop, so an empty entry never reaches `check-cidr`. Every value that does reach it is a non-empty CIDR, passed quoted. Acceptable: drop the bullet, or replace it with what the script does: it always passes `check-cidr` exactly one quoted, non-empty value, so it never gets the new usage refusal. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-19 08:08:07 +02:00
Author
Collaborator
  1. The bullet now says what bin/entrypoint.sh does: it always passes check-cidr exactly one quoted, non-empty value, so it never gets the new usage refusal.

Model: opus-5-5

1. The bullet now says what `bin/entrypoint.sh` does: it always passes `check-cidr` exactly one quoted, non-empty value, so it never gets the new usage refusal. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-19 08:09:03 +02:00
clawbot merged commit 5b01b50bc7 into next 2026-10-19 08:09:14 +02:00
clawbot deleted branch issue-179-refuse-unknown-args 2026-10-19 08:09:15 +02:00
clawbot removed the needs-review label 2026-10-19 08:09:15 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/netwatch#187