Skip to main content

parse_command_text_with_aliases

Function parse_command_text_with_aliases 

Source
pub fn parse_command_text_with_aliases(
    text: &str,
    config: &ResolvedConfig,
) -> Result<ParsedCommandLine>
Expand description

Parses a raw command line, expands aliases, and separates trailing DSL stages.

This is the text-entry path used by CLI and REPL surfaces when they need one parser pass that understands both shell words and trailing pipes.

ยงExamples

use osp_cli::cli::parse_command_text_with_aliases;
use osp_cli::config::{ConfigLayer, ConfigResolver, ResolveOptions};

let mut defaults = ConfigLayer::default();
defaults.set("profile.default", "default");

let mut resolver = ConfigResolver::default();
resolver.set_defaults(defaults);
let config = resolver.resolve(ResolveOptions::default()).unwrap();

let parsed = parse_command_text_with_aliases("theme show dracula | H P", &config).unwrap();
assert_eq!(parsed.tokens, vec!["theme", "show", "dracula"]);
assert_eq!(parsed.stages, vec!["H P"]);