pub fn parse_inline_command_tokens(
tokens: &[String],
) -> Result<Option<Commands>, Error>Expand description
Parses inline command tokens with the same clap model as the top-level CLI.
This is the REPL-facing path for turning already-tokenized input into a
concrete builtin command, and it returns Ok(None) when no subcommand has
been selected yet.
ยงExamples
use osp_cli::cli::{Commands, ThemeCommands, parse_inline_command_tokens};
let tokens = vec![
"theme".to_string(),
"show".to_string(),
"dracula".to_string(),
];
let command = parse_inline_command_tokens(&tokens).unwrap().unwrap();
match command {
Commands::Theme(args) => match args.command {
ThemeCommands::Show(show) => {
assert_eq!(show.name.as_deref(), Some("dracula"));
}
other => panic!("unexpected theme command: {other:?}"),
},
other => panic!("unexpected command: {other:?}"),
}