Skip to main content

Module cli

Module cli 

Source
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 dispatch

Most callers only need a few entry points:

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 osp command.
ConfigArgs
Top-level config command arguments.
ConfigExplainArgs
Arguments for config explain.
ConfigGetArgs
Arguments for config get.
ConfigReadOutputArgs
Shared config read-output arguments.
ConfigScopeArgs
Shared config write scope arguments.
ConfigSetArgs
Arguments for config set.
ConfigShowArgs
Arguments for config show.
ConfigStoreArgs
Shared config store-selection arguments.
ConfigUnsetArgs
Arguments for config unset.
DebugCompleteArgs
Arguments for REPL completion debugging.
DebugHighlightArgs
Arguments for REPL highlighting debugging.
DoctorArgs
Top-level doctor command arguments.
HistoryArgs
Top-level history command arguments.
HistoryPruneArgs
Arguments for history prune.
InlineCommandCli
Parser used for inline command execution without the binary name prefix.
IntroArgs
Hidden intro command arguments.
ParsedCommandLine
Parsed command tokens plus trailing DSL stages.
PluginCommandClearArgs
Arguments for clearing persisted command state.
PluginCommandStateArgs
Shared arguments for enabling or disabling a plugin command.
PluginCommandTargetArgs
Shared plugin command target arguments.
PluginConfigArgs
Arguments for plugins config.
PluginProviderClearArgs
Arguments for clearing a provider selection.
PluginProviderSelectArgs
Arguments for selecting a provider implementation for a command.
PluginScopeArgs
Shared arguments for enabling or disabling a plugin command.
PluginsArgs
Top-level plugin command arguments.
ReplArgs
Hidden REPL-only command namespace.
ThemeArgs
Top-level theme command arguments.
ThemeShowArgs
Arguments for theme show.
ThemeUseArgs
Arguments for theme use.

Enums§

Commands
Top-level commands accepted by osp.
ConfigCommands
Configuration inspection and mutation commands.
DebugMenuArg
Popup menu target to inspect through the hidden REPL debug surface.
DoctorCommands
Built-in diagnostic groups exposed through osp doctor.
HistoryCommands
History management commands.
PluginsCommands
Built-in plugin management subcommands.
ReplCommands
Hidden REPL debugging commands.
ThemeCommands
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.