Skip to main content

parse_repl_command

Function parse_repl_command 

Source
pub fn parse_repl_command(tokens: &[String]) -> Result<ParsedCommand>
Expand description

Interprets tokenized service-layer input using the minimal LDAP command grammar.

Unlike the full CLI parser, this only accepts the LDAP-only subset modeled by ParsedCommand.

ยงExamples

use osp_cli::services::{ParsedCommand, parse_repl_command};

let tokens = vec![
    "ldap".to_string(),
    "user".to_string(),
    "alice".to_string(),
    "--attributes".to_string(),
    "uid,mail".to_string(),
];

let parsed = parse_repl_command(&tokens).unwrap();
assert!(matches!(
    parsed,
    ParsedCommand::LdapUser {
        uid: Some(uid),
        attributes: Some(attributes),
        ..
    } if uid == "alice" && attributes == "uid,mail"
));