Expand description
Command-line argument types and CLI parsing helpers.
The CLI module exists to define the public command-line grammar of osp.
This module owns the public command-line grammar for osp: top-level
commands, shared flags, inline parsing helpers, and the bridge from CLI
arguments into render/config runtime settings. It does not execute commands;
that handoff happens in crate::app.
Read this module when you need to answer:
- what is a valid
osp ...command line? - which flags are persistent config versus one-shot invocation settings?
- how does the REPL reuse the same grammar without reusing process argv?
Broad-strokes flow:
process argv or REPL line
│
▼
[ Cli / InlineCommandCli ]
clap grammar for builtins and shared flags
│
├── [ invocation ] one-shot execution/render flags (`--format`, `-v`,
│ `--cache`, `--plugin-provider`, ...)
├── [ pipeline ] alias-aware command token parsing plus DSL stages
└── [ commands ] built-in command handlers once parsing is complete
│
▼
[ app ] host orchestration and final dispatchMost callers only need a few entry points:
crate::cli::Clifor the binary-facing grammarcrate::cli::InlineCommandClifor command text that omits the binary namecrate::cli::parse_command_text_with_aliaseswhen you need alias-aware command plus DSL parsing
The split here is deliberate. One-shot flags that affect rendering or dispatch should be modeled here so CLI, REPL, tests, and embedders all see the same contract. Do not let individual command handlers invent their own side-channel parsing rules or hidden output flags.
Contract:
- this module defines what users are allowed to type
- it may translate flags into config/render settings
- it should not dispatch commands, query external systems, or own REPL editor behavior
Structs§
- Cli
- Top-level CLI parser for the
ospcommand. - Config
Args - Top-level config command arguments.
- Config
Explain Args - Arguments for
config explain. - Config
GetArgs - Arguments for
config get. - Config
Read Output Args - Shared config read-output arguments.
- Config
Scope Args - Shared config write scope arguments.
- Config
SetArgs - Arguments for
config set. - Config
Show Args - Arguments for
config show. - Config
Store Args - Shared config store-selection arguments.
- Config
Unset Args - Arguments for
config unset. - Debug
Complete Args - Arguments for REPL completion debugging.
- Debug
Highlight Args - Arguments for REPL highlighting debugging.
- Doctor
Args - Top-level doctor command arguments.
- History
Args - Top-level history command arguments.
- History
Prune Args - Arguments for
history prune. - Inline
Command Cli - Parser used for inline command execution without the binary name prefix.
- Intro
Args - Hidden intro command arguments.
- Parsed
Command Line - Parsed command tokens plus trailing DSL stages.
- Plugin
Command Clear Args - Arguments for clearing persisted command state.
- Plugin
Command State Args - Shared arguments for enabling or disabling a plugin command.
- Plugin
Command Target Args - Shared plugin command target arguments.
- Plugin
Config Args - Arguments for
plugins config. - Plugin
Provider Clear Args - Arguments for clearing a provider selection.
- Plugin
Provider Select Args - Arguments for selecting a provider implementation for a command.
- Plugin
Scope Args - Shared arguments for enabling or disabling a plugin command.
- Plugins
Args - Top-level plugin command arguments.
- Repl
Args - Hidden REPL-only command namespace.
- Theme
Args - Top-level theme command arguments.
- Theme
Show Args - Arguments for
theme show. - Theme
UseArgs - Arguments for
theme use.
Enums§
- Commands
- Top-level commands accepted by
osp. - Config
Commands - Configuration inspection and mutation commands.
- Debug
Menu Arg - Popup menu target to inspect through the hidden REPL debug surface.
- Doctor
Commands - Built-in diagnostic groups exposed through
osp doctor. - History
Commands - History management commands.
- Plugins
Commands - Built-in plugin management subcommands.
- Repl
Commands - Hidden REPL debugging commands.
- Theme
Commands - Theme inspection and selection commands.
Functions§
- is_
cli_ help_ stage - Reports whether a parsed stage is the special CLI help form
| H <verb>. - parse_
command_ text_ with_ aliases - Parses a raw command line, expands aliases, and separates trailing DSL stages.
- parse_
command_ tokens_ with_ aliases - Finalizes already-tokenized input into command tokens plus DSL stages.
- parse_
inline_ command_ tokens - Parses inline command tokens with the same clap model as the top-level CLI.
- validate_
cli_ dsl_ stages - Validates that every CLI pipe stage is known to the DSL surface.