Expand description
Central command registry with lookup and search operations.
Registry is the primary store for the command tree in an argot
application. It owns a Vec<Command> and exposes several query methods:
Registry::get_command— exact lookup by canonical name.Registry::get_subcommand— walk a path of canonical names into the nested subcommand tree.Registry::list_commands— iterate all top-level commands.Registry::search— case-insensitive substring search across canonical name, summary, and description.Registry::fuzzy_search— fuzzy (skim) search returning results sorted by score (best match first). Requires thefuzzyfeature.Registry::to_json— serialize the command tree to pretty-printed JSON (handler closures are excluded).
Pass registry.commands() to crate::Parser::new to wire the registry
into the parsing pipeline.
§Example
let registry = Registry::new(vec![
Command::builder("list").summary("List all items").build().unwrap(),
Command::builder("get").summary("Get a single item").build().unwrap(),
]);
assert!(registry.get_command("list").is_some());
assert_eq!(registry.search("item").len(), 2);Structs§
- Command
Entry - A command paired with its canonical path from the registry root.
- Registry
- Owns the registered command tree and provides query/search operations.
Enums§
- Query
Error - Errors produced by
Registrymethods.
Functions§
- command_
to_ json_ with_ fields - Serialize a single
Commandto a pretty-printed JSON string, filtering the output to only include the requested top-level fields. - command_
to_ ndjson - Serialize a single
Commandto a compact (single-line) JSON string.