Skip to main content

reovim_driver_command/
lib.rs

1#![cfg_attr(coverage_nightly, allow(unused_features))]
2#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
3//! Command driver for reovim - command execution framework.
4//!
5//! Linux equivalent: `drivers/block/` (block command interface)
6//!
7//! # Architecture
8//!
9//! This crate defines the command execution framework for reovim.
10//! Commands implement [`Command`] for metadata and [`CommandHandler`] for execution.
11//!
12//! ```text
13//! server/lib/drivers/command/  <-- Command framework (this crate)
14//!        ^
15//!        |  (modules implement commands)
16//!        |
17//! server/modules/              <-- Policy: actual command implementations
18//! ```
19//!
20//! # Components
21//!
22//! - [`Command`] - Self-describing command metadata
23//! - [`CommandHandler`] - Command execution trait
24//! - [`ArgSpec`] - Argument specification
25//! - [`ArgKind`], [`ArgValue`] - Argument types
26//! - [`CommandContext`] - Context carrying all command inputs
27//! - [`CommandResult`] - Command execution result
28//!
29//! # Example
30//!
31//! ```ignore
32//! use reovim_driver_command::{Command, CommandHandler, CommandContext, CommandResult, ArgSpec, ArgKind};
33//! use reovim_driver_session::SessionRuntime;
34//! use reovim_kernel::api::v1::{CommandId, ModuleId};
35//!
36//! const MY_MODULE: ModuleId = ModuleId::new_const("my-module");
37//!
38//! pub struct CursorDown;
39//!
40//! impl Command for CursorDown {
41//!     fn id(&self) -> CommandId {
42//!         CommandId::new(MY_MODULE, "cursor-down")
43//!     }
44//!
45//!     fn description(&self) -> &'static str {
46//!         "Move cursor down"
47//!     }
48//!
49//!     fn args(&self) -> Vec<ArgSpec> {
50//!         vec![ArgSpec::optional("count", ArgKind::Count, "Number of lines")]
51//!     }
52//! }
53//!
54//! impl CommandHandler for CursorDown {
55//!     fn execute(&self, runtime: &mut SessionRuntime<'_>, args: &CommandContext) -> CommandResult {
56//!         let count = args.count().unwrap_or(1);
57//!         // Move cursor down by count lines using runtime.kernel() escape hatch
58//!         // or BufferApi methods
59//!         CommandResult::Success
60//!     }
61//! }
62//! ```
63
64// Internal modules
65mod name_index;
66mod parse;
67mod provider;
68mod query;
69mod registry;
70mod traits;
71
72// Re-export from command-types for backwards compatibility
73pub use reovim_driver_command_types::{
74    ArgKind, ArgSpec, ArgValue, CommandContext, CommandResult, MotionType, RuntimeSignal,
75};
76
77// Re-export provider trait
78pub use provider::CommandProvider;
79
80// Re-export registry for ServiceRegistry (Epic #417 Part 3)
81pub use registry::CommandHandlerStore;
82
83// Re-export query service (#453, #522)
84pub use query::{CommandInfo, CommandQueryProvider, CommandQueryService};
85
86// Re-export name index and cmdline parser (#547, #559, #561)
87pub use {
88    name_index::{AmbiguousPrefix, CommandNameIndex},
89    parse::{ArgError, ParsedCmdline, bind_args, parse_cmdline, tokenize_args},
90};
91
92// Re-export traits
93pub use traits::{Command, CommandHandler, CommandPriority};
94
95#[cfg(test)]
96#[path = "lib_tests.rs"]
97mod tests;