fix(cli): handle --help/--version, error on unknown args (#21) #22

Merged
mik-tf merged 1 commit from fix/21-help-version-flags into development 2026-05-06 14:21:10 +00:00
Owner

Summary

The hero_browser_server binary did no argument parsing — any flag, including --help and --version, fell through and started the daemon. Any tool probing the binary with --help (CLI introspection, completion generators, packaging tools) would accidentally launch a server.

Fixes #21.

Changes

Small hand-rolled arg matcher in main():

  • -h / --help → print usage, exit 0
  • -V / --version → print hero_browser_server <CARGO_PKG_VERSION>, exit 0
  • Unknown flag → error to stderr referencing --help, exit 2
  • Bare invocation → start the server (unchanged)

No new deps. The binary is intentionally minimal per its module-level doc comment, so clap derive felt heavy for two flags.

Test plan

Verified manually on Linux x86_64 with the rebuilt release binary:

$ hero_browser_server --help    → exit 0, usage printed, no listener
$ hero_browser_server -h        → exit 0, usage printed, no listener
$ hero_browser_server --version → exit 0, prints `hero_browser_server 0.1.0`
$ hero_browser_server -V        → exit 0, prints `hero_browser_server 0.1.0`
$ hero_browser_server --foo     → exit 2, error to stderr, no listener
$ hero_browser_server           → server starts, binds tcp:8884 + unix socket, /health and /mcp respond

MCP tools/list round-trip verified against the running daemon after install. No regressions to the bare-invocation path.

## Summary The `hero_browser_server` binary did no argument parsing — any flag, including `--help` and `--version`, fell through and started the daemon. Any tool probing the binary with `--help` (CLI introspection, completion generators, packaging tools) would accidentally launch a server. Fixes #21. ## Changes Small hand-rolled arg matcher in `main()`: - `-h` / `--help` → print usage, exit 0 - `-V` / `--version` → print `hero_browser_server <CARGO_PKG_VERSION>`, exit 0 - Unknown flag → error to stderr referencing `--help`, exit 2 - Bare invocation → start the server (unchanged) No new deps. The binary is intentionally minimal per its module-level doc comment, so `clap` derive felt heavy for two flags. ## Test plan Verified manually on Linux x86_64 with the rebuilt release binary: ``` $ hero_browser_server --help → exit 0, usage printed, no listener $ hero_browser_server -h → exit 0, usage printed, no listener $ hero_browser_server --version → exit 0, prints `hero_browser_server 0.1.0` $ hero_browser_server -V → exit 0, prints `hero_browser_server 0.1.0` $ hero_browser_server --foo → exit 2, error to stderr, no listener $ hero_browser_server → server starts, binds tcp:8884 + unix socket, /health and /mcp respond ``` MCP `tools/list` round-trip verified against the running daemon after install. No regressions to the bare-invocation path.
fix(cli): handle --help/--version, error on unknown args (#21)
Some checks failed
Test / test (pull_request) Failing after 2s
Build and Test / build (pull_request) Successful in 5m2s
a31b077b94
The binary did no argument parsing at all, so any flag — including
`--help` and `--version` — fell through to `run_server()` and started
the daemon. Tools that probe a binary with `--help` to discover its
CLI surface accidentally launched a server.

Add a small hand-rolled matcher in `main()` for `-h`/`--help`,
`-V`/`--version`, and unknown-flag rejection. No new deps; the binary
is intentionally minimal per its module-level docs.

Closes #21

Signed-off-by: mik-tf <logismos@protonmail.ch>
mik-tf merged commit 269ca26a50 into development 2026-05-06 14:21:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_browser!22
No description provided.