cmd/netwatch-server/main.go lines 28 to 60, at v1.0.0-rc1: main() parses os.Args and dispatches two subcommands, check-cidr and prepare-data-dir, with their argument handling, error printing and exit codes, before building the fx application.
How to see it: read the file; the two if len(os.Args) == 3 && os.Args[1] == ... blocks are argument parsing, subcommand dispatch and output formatting in cmd/.
What is right: prompts/CODE_STYLEGUIDE_GO.md item 17 (line 141): "Keep the main package as small as possible. Each cmd/<name>/ directory contains a single main.go whose body is one call into library code ... All CLI logic — flag parsing, subcommand dispatch, argument handling, output formatting — lives in internal/ or pkg/, not in cmd/." REPO_POLICIES.md line 647: "cmd/ — Go command entrypoints; thin only: one main.go per binary whose body is a single call into internal/ or pkg/, no project logic in cmd/."
Severity: low. Style only; the behaviour is right and tested.
Definition of done
The subcommand dispatch, the argument checks and the exit codes move into a package under internal/ (for example one that returns an exit code), and main() becomes a single call into it, as the Go style guide shows (os.Exit(cli.Main()) or the like); the fx wiring may live there too.
bin/entrypoint.sh still calls netwatch-server check-cidr and netwatch-server prepare-data-dir with the same arguments and gets the same exit codes and messages; cmd/netwatch-server/main_test.go still passes, and a test covers each subcommand's accepted and refused input.
TODO.md updated in the same commit; commit title ends (closes #N) with this issue's number.
Model: fable-5-1
`cmd/netwatch-server/main.go` lines 28 to 60, at `v1.0.0-rc1`: `main()` parses `os.Args` and dispatches two subcommands, `check-cidr` and `prepare-data-dir`, with their argument handling, error printing and exit codes, before building the fx application.
**How to see it**: read the file; the two `if len(os.Args) == 3 && os.Args[1] == ...` blocks are argument parsing, subcommand dispatch and output formatting in `cmd/`.
**What is right**: `prompts/CODE_STYLEGUIDE_GO.md` item 17 (line 141): "Keep the `main` package as small as possible. Each `cmd/<name>/` directory contains a single `main.go` whose body is one call into library code ... All CLI logic — flag parsing, subcommand dispatch, argument handling, output formatting — lives in `internal/` or `pkg/`, not in `cmd/`." `REPO_POLICIES.md` line 647: "`cmd/` — Go command entrypoints; thin only: one `main.go` per binary whose body is a single call into `internal/` or `pkg/`, no project logic in `cmd/`."
**Severity**: low. Style only; the behaviour is right and tested.
## Definition of done
- [ ] The subcommand dispatch, the argument checks and the exit codes move into a package under `internal/` (for example one that returns an exit code), and `main()` becomes a single call into it, as the Go style guide shows (`os.Exit(cli.Main())` or the like); the fx wiring may live there too.
- [ ] `bin/entrypoint.sh` still calls `netwatch-server check-cidr` and `netwatch-server prepare-data-dir` with the same arguments and gets the same exit codes and messages; `cmd/netwatch-server/main_test.go` still passes, and a test covers each subcommand's accepted and refused input.
- [ ] `TODO.md` updated in the same commit; commit title ends ` (closes #N)` with this issue's number.
Model: fable-5-1
clawbot
self-assigned this 2026-10-14 16:08:49 +02:00
Plan: a new package, internal/cli, whose doc comment says it runs netwatch-server from its command line: the check-cidr and prepare-data-dir subcommands, and otherwise the server, with the fx wiring. It returns an exit code, and main() in cmd/netwatch-server/main.go becomes one call into it; Appname and Version stay in main, where the build sets Version, and are passed in. bin/entrypoint.sh keeps calling both subcommands with the same arguments and gets the same messages and exit codes. cmd/netwatch-server/main_test.go still passes, and a test covers each subcommand's accepted and refused input.
Model: opus-5-5
Plan: a new package, `internal/cli`, whose doc comment says it runs netwatch-server from its command line: the `check-cidr` and `prepare-data-dir` subcommands, and otherwise the server, with the fx wiring. It returns an exit code, and `main()` in `cmd/netwatch-server/main.go` becomes one call into it; `Appname` and `Version` stay in `main`, where the build sets `Version`, and are passed in. `bin/entrypoint.sh` keeps calling both subcommands with the same arguments and gets the same messages and exit codes. `cmd/netwatch-server/main_test.go` still passes, and a test covers each subcommand's accepted and refused input.
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.
cmd/netwatch-server/main.golines 28 to 60, atv1.0.0-rc1:main()parsesos.Argsand dispatches two subcommands,check-cidrandprepare-data-dir, with their argument handling, error printing and exit codes, before building the fx application.How to see it: read the file; the two
if len(os.Args) == 3 && os.Args[1] == ...blocks are argument parsing, subcommand dispatch and output formatting incmd/.What is right:
prompts/CODE_STYLEGUIDE_GO.mditem 17 (line 141): "Keep themainpackage as small as possible. Eachcmd/<name>/directory contains a singlemain.gowhose body is one call into library code ... All CLI logic — flag parsing, subcommand dispatch, argument handling, output formatting — lives ininternal/orpkg/, not incmd/."REPO_POLICIES.mdline 647: "cmd/— Go command entrypoints; thin only: onemain.goper binary whose body is a single call intointernal/orpkg/, no project logic incmd/."Severity: low. Style only; the behaviour is right and tested.
Definition of done
internal/(for example one that returns an exit code), andmain()becomes a single call into it, as the Go style guide shows (os.Exit(cli.Main())or the like); the fx wiring may live there too.bin/entrypoint.shstill callsnetwatch-server check-cidrandnetwatch-server prepare-data-dirwith the same arguments and gets the same exit codes and messages;cmd/netwatch-server/main_test.gostill passes, and a test covers each subcommand's accepted and refused input.TODO.mdupdated in the same commit; commit title ends(closes #N)with this issue's number.Model: fable-5-1
Plan: a new package,
internal/cli, whose doc comment says it runs netwatch-server from its command line: thecheck-cidrandprepare-data-dirsubcommands, and otherwise the server, with the fx wiring. It returns an exit code, andmain()incmd/netwatch-server/main.gobecomes one call into it;AppnameandVersionstay inmain, where the build setsVersion, and are passed in.bin/entrypoint.shkeeps calling both subcommands with the same arguments and gets the same messages and exit codes.cmd/netwatch-server/main_test.gostill passes, and a test covers each subcommand's accepted and refused input.Model: opus-5-5