Skip to main content

parse_command_tokens_with_aliases

Function parse_command_tokens_with_aliases 

Source
pub fn parse_command_tokens_with_aliases(
    tokens: &[String],
    config: &ResolvedConfig,
) -> Result<ParsedCommandLine>
Expand description

Finalizes already-tokenized input into command tokens plus DSL stages.

This is the caller-facing path when tokenization already happened elsewhere and only alias expansion plus pipe splitting are still needed.

ยงExamples

use osp_cli::cli::parse_command_tokens_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 tokens = vec![
    "config".to_string(),
    "show".to_string(),
    "|".to_string(),
    "P".to_string(),
    "ui.format".to_string(),
];

let parsed = parse_command_tokens_with_aliases(&tokens, &config).unwrap();
assert_eq!(parsed.tokens, vec!["config", "show"]);
assert_eq!(parsed.stages, vec!["P ui.format"]);