pub trait CommandQueryService:
Service
+ Send
+ Sync {
// Required methods
fn search_by_prefix(&self, prefix: &str) -> Vec<CommandInfo>;
fn find_by_name(&self, name: &str) -> Option<CommandInfo>;
fn list_user_commands(&self) -> Vec<CommandInfo>;
fn list_all(&self) -> Vec<CommandInfo>;
fn count(&self) -> usize;
}Expand description
Query service for command discovery and completion.
Modules access this via ServiceRegistry to implement features
like tab-completion without depending on runner internals.
§Thread Safety
Implementations must be thread-safe (Send + Sync).
§Example
ⓘ
// In cmdline module for tab completion:
let query = services.get::<dyn CommandQueryService>()?;
let matches = query.search_by_prefix("wri");
// matches contains CommandInfo for "write", etc.Required Methods§
Sourcefn search_by_prefix(&self, prefix: &str) -> Vec<CommandInfo>
fn search_by_prefix(&self, prefix: &str) -> Vec<CommandInfo>
Search commands by name prefix (for tab completion).
Returns commands where any alias starts with prefix.
The search is case-sensitive.
An empty prefix returns all commands (every string starts with "").
§Example
ⓘ
let matches = query.search_by_prefix("wri");
// Returns CommandInfo for commands with aliases like "write"Sourcefn find_by_name(&self, name: &str) -> Option<CommandInfo>
fn find_by_name(&self, name: &str) -> Option<CommandInfo>
Sourcefn list_user_commands(&self) -> Vec<CommandInfo>
fn list_user_commands(&self) -> Vec<CommandInfo>
List all commands that have user-facing names.
Returns only commands where names() is non-empty.
Use this for cmdline completion UI.
Sourcefn list_all(&self) -> Vec<CommandInfo>
fn list_all(&self) -> Vec<CommandInfo>
List all registered commands.
Includes commands without ex-names (internal commands).