Skip to main content

Module args

Module args 

Source
Expand description

CLI argument parsing + help text. Mirrors the TS packages/coding-agent/src/cli/args.ts (parseArgs + printHelp), scoped to the flags the v1 Rust CLI honors.

The TS parser is a hand-rolled positional/flag loop (no yargs/commander dep) that collects messages, @file attachments, known flags, and a map of unknown --flags (for extensions to claim later). This port keeps the same shape so the help text and flag semantics line up 1:1 with the reference. Unknown flags are not stored (there is no extension system in v1); they produce a warning diagnostic instead.

Divergences from the TS parser (all deliberate v1 scope cuts, documented in docs/m6-cli-open-questions.md):

  • --mode rpc, --tui-mode, --export, --list-models, --models, --fork, --offline, --approve/-na, the package-manager subcommands, --extension/-e, --skill, --prompt-template, --theme, and their --no-* discovery toggles are recognized but ignored (parsed so users don’t get a hard error for muscle-memory flags, with a warning). They are not in v1’s surface.
  • --thinking is typed via ThinkingLevel from rpi_ai (the TS parser validates against the same string set).
  • --print/-p may consume a following positional as its prompt (the TS parser’s next !== undefined && !startsWith('@') heuristic) — preserved.

Structs§

Args
The parsed argument set. Mirrors TS Args. Fields absent in v1 (unknownFlags, extension/resource discovery) are omitted; everything here is either honored or explicitly ignored-with-warning.

Enums§

Mode
Output mode. Mirrors TS Mode = "text" | "json" | "rpc". rpc is parsed (so --mode rpc doesn’t error) but v1 does not implement it; main reports an error if selected.
RunMode
The concrete run mode resolve_mode picks. Mirrors TS AppMode (interactive/print/json/rpc). Distinguished from Mode (the raw --mode flag value) because the effective mode also folds in -p + TTY detection.

Constants§

VALID_THINKING_LEVELS
The canonical valid --thinking level strings, in level order. Mirrors TS VALID_THINKING_LEVELS.

Functions§

parse_args
Parse argv (excluding the program name). Mirrors TS parseArgs.
parse_thinking_level
Parse a thinking-level string. Mirrors TS isValidThinkingLevel.
print_help
Print the help text to stdout. Mirrors TS printHelp, scoped to v1 flags.
print_version
Print the version line. Mirrors TS --version output (pi <version>).
resolve_mode
Resolve the effective output Mode. Mirrors TS resolveAppMode: rpc→rpc, json→json, print or piped-stdin/redirected-stdout→print, else interactive. Here stdin_is_tty/stdout_is_tty come from std::io::IsTerminal.