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 long flags are retained in Args::unknown_flags so a
native extension can claim and consume its own CLI options after loading.
Divergences from the TS parser (all deliberate v1 scope cuts, documented in
docs/m6-cli-open-questions.md):
--mode rpc,--fork,--approve/-na,--extension/-e,--skill, and--prompt-templateare recognized but not all wired into the full TS package manager. The supported resource flags are handled by the Rust loader; remaining compatibility flags are accepted with a warning.--thinkingis typed viaThinkingLevelfromrpi_ai(the TS parser validates against the same string set).--print/-pmay consume a following positional as its prompt (the TS parser’snext !== undefined && !startsWith('@')heuristic) — preserved.
Structs§
- Args
- The parsed argument set. Mirrors TS
Args. Unknown long flags are retained for extension consumption; unknown short flags remain hard errors.
Enums§
- Mode
- Output mode. Mirrors TS
Mode = "text" | "json" | "rpc".rpcis parsed (so--mode rpcdoesn’t error) but v1 does not implement it;mainreports an error if selected. - RunMode
- The concrete run mode
resolve_modepicks. Mirrors TSAppMode(interactive/print/json/rpc). Distinguished fromMode(the raw--modeflag value) because the effective mode also folds in-p+ TTY detection. - TuiMode
- Interactive TUI presentation mode.
fullscreenuses the alternate screen buffer;regularrenders into the terminal’s normal scrollback.
Constants§
- VALID_
THINKING_ LEVELS - The canonical valid
--thinkinglevel strings, in level order. Mirrors TSVALID_THINKING_LEVELS.
Functions§
- parse_
args - Parse
argv(excluding the program name). Mirrors TSparseArgs. - 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
--versionoutput (pi <version>). - resolve_
mode - Resolve the effective output
Mode. Mirrors TSresolveAppMode:rpc→rpc,json→json,printor piped-stdin/redirected-stdout→print, else interactive. Herestdin_is_tty/stdout_is_ttycome fromstd::io::IsTerminal.