Hmbown/CodeWhale · info

Usage: /network

Error message

Usage: /network {command} <host>

What it means

Usage error from the `/network` slash command: a host-taking subcommand (`allow`, `deny`, `remove`, or `forget`) was invoked without exactly one host argument — either the host was omitted or extra arguments followed it. Raised in `network_inner` (called by `network`), which parses the raw argument by whitespace. The command prints this usage line instead of silently guessing.

Solutions

  1. Supply exactly one host: `/network allow api.example.com` or `/network deny evil.dev`.
  2. Remove extra tokens — hosts must be a single whitespace-free argument; quote-stripping is not performed.
  3. Use `/network list` (or bare `/network`) to view the policy, and `/network default allow|deny|prompt` for the default posture — neither takes a host.
  4. Check `/network` usage output for the accepted subcommand grammar.

Example fix

// before
/network allow
// after
/network allow api.example.com
Defensive patterns

Strategy: validation

Validate before calling

// shell-side guard before invoking the command
read -r sub host extra <<< "$input"
case "$sub" in
  allow|deny|remove|forget) [ -n "$host" ] && [ -z "$extra" ] || echo "Usage: /network $sub <host>" ;;
esac

Try / catch

// the command returns CommandResult::error(err.to_string()) — display it as-is;
// no retry: this is a usage error, correct the arguments and re-run.
match result {
  CommandResult::Error(msg) if msg.starts_with("Usage: /network") => print_help("/network"),
  other => other,
}

Prevention

When it happens

Trigger: Running `/network allow`, `/network deny`, `/network remove`, or `/network forget` with no host (`/network allow`) or with more than one trailing token (`/network allow example.com extra`).

Common situations: Typing the subcommand and forgetting the host; pasting a multi-token value like `example.com:443 proxy`; using `forget` as an alias while expecting `default`-style syntax (`/network forget` alone); thinking `list` needs a host.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/commands/groups/utility/network.rs:55

    }
}

fn network_inner(arg: Option<&str>) -> anyhow::Result<String> {
    let raw = arg.map(str::trim).unwrap_or("");
    if raw.is_empty() || raw.eq_ignore_ascii_case("list") {
        return list_policy();
    }

    let mut parts = raw.split_whitespace();
    let Some(command) = parts.next() else {
        return list_policy();
    };
    let command = command.to_ascii_lowercase();

    match command.as_str() {
        "allow" | "deny" | "remove" | "forget" => {
            let Some(host_arg) = parts.next() else {
                bail!("Usage: /network {command} <host>");
            };
            if parts.next().is_some() {
                bail!("Usage: /network {command} <host>");
            }
            let host = normalize_host_arg(host_arg)?;
            let edit = match command.as_str() {
                "allow" => NetworkEdit::Allow,
                "deny" => NetworkEdit::Deny,
                _ => NetworkEdit::Remove,
            };
            update_host(edit, &host)
        }
        "default" => {
            let Some(value) = parts.next() else {
                bail!("Usage: /network default <allow|deny|prompt>");
            };
            if parts.next().is_some() {
                bail!("Usage: /network default <allow|deny|prompt>");

View on GitHub (pinned to 73e0f67d83)