pub fn execute_line<L: LdapDirectory>(
ctx: &ServiceContext<L>,
line: &str,
) -> Result<OutputResult>Expand description
Executes one LDAP service command line and applies any trailing DSL stages.
This is the small, embeddable surface for callers that want LDAP command parsing plus pipelines without bootstrapping the full CLI host.
The full line is parsed as <command> [| <stage> ...]. The command is
dispatched against the ports in ctx; the stages are applied to the
returned rows before the result is returned.
Only the ldap user ... and ldap netgroup ... roots are supported today.
ยงExamples
use osp_cli::config::RuntimeConfig;
use osp_cli::ports::mock::MockLdapClient;
use osp_cli::services::{ServiceContext, execute_line};
let ctx = ServiceContext::new(
Some("oistes".to_string()),
MockLdapClient::default(),
RuntimeConfig::default(),
);
// `MockLdapClient::default()` exposes a fixed `oistes` user fixture.
let result = execute_line(&ctx, "ldap user oistes | F uid=oistes | P uid cn")
.expect("command and pipeline should run");
let rows = result.as_rows().expect("expected row output");
assert_eq!(rows.len(), 1);
assert_eq!(rows[0].get("uid").and_then(|value| value.as_str()), Some("oistes"));
assert!(rows[0].contains_key("cn"));