Hmbown/CodeWhale · error · anyhow::Error

Usage: codewhale pet serve

Error message

Usage: codewhale pet serve

What it means

The `pet` subcommand dispatches on its positional arguments; the `serve` pet action expects a specific argument shape (including an optional port). Any other pet subcommand or malformed argument list falls into the catch-all `_` arm and bails with a usage string.

Solutions

  1. Run `codewhale pet serve` exactly, optionally followed by a numeric port (defaults to 4633)
  2. Check `codewhale --help` / `codewhale pet --help` for the valid subcommands
  3. Quote or drop unexpected arguments so the match arm pattern succeeds

Example fix

// before
codewhale pet serve --port 5000
// after
codewhale pet serve 5000
Defensive patterns

Strategy: validation

Validate before calling

// only invoke the exact known form:
// codewhale pet serve [PORT]  where PORT is a valid u16

Try / catch

match result { Err(e) if e.to_string().starts_with("Usage: codewhale pet serve") => { eprintln!("{}", e); std::process::exit(2); }, other => other? }

Prevention

When it happens

Trigger: Running `codewhale pet` with an unrecognized sub-action, or `codewhale pet serve` arguments that fail to match the expected pattern (e.g. `serve` with an invalid extra token that doesn't parse as u16, or arguments in the wrong order).

Common situations: Typo in the pet subcommand name; passing flags the pet parser doesn't know; supplying a non-numeric port to serve; guessing subcommand syntax.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/8ac974cd50c63d78. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:1748

    // resolved to danger-full-access skips PR_SET_NO_NEW_PRIVS (#5723), every
    // other outcome keeps it.
    let startup_sandbox_mode = resolve_startup_sandbox_mode_for_hardening();
    crate::sandbox::process_hardening::apply_process_hardening(startup_sandbox_mode.as_deref());

    if args.get(1).is_some_and(|arg| arg == "pet") {
        let root = crate::tui::pet_watch::owner::directory()?;
        match args.get(2).map(String::as_str) {
            Some("serve") if args.len() == 3 => {
                return crate::tui::pet_watch::owner::serve(
                    root,
                    std::env::var("CODEWHALE_PET_PORT")
                        .ok()
                        .map(|p| p.parse::<u16>())
                        .transpose()?
                        .unwrap_or(4633),
                );
            }
            _ => anyhow::bail!("Usage: codewhale pet serve"),
        }
    }

    // ── Fatal-signal terminal guard (#5424) ───────────────────────────────
    // Abort-class deaths (stack overflow, allocation failure, double panic)
    // skip the panic hook AND every Drop guard, leaving mouse capture and
    // the kitty keyboard stack leaking into the user's shell. A classic
    // sigaction handler restores the terminal and stamps a marker before
    // re-raising. Also before any threads exist.
    crate::tui::ui::fatal_signal_guard::install_fatal_signal_guard();

    // Set up process panic hook before anything else — writes crash dumps
    // to ~/.deepseek/crashes/ even if the panic happens before tokio is up,
    // and restores the terminal so a panicked TUI doesn't leave the user's
    // shell stuck in alt-screen mode.
    let orig_hook = std::panic::take_hook();
    std::panic::set_hook(Box::new(move |panic_info| {
        // Restore the terminal first so the panic message itself, plus the

View on GitHub (pinned to 73e0f67d83)