pub struct Console { /* private fields */ }Expand description
控制台应用 — 命令注册表与分发器
对齐 PHP think\console\Console。允许在运行时注册自定义命令,
并列出所有可用命令。
§分发逻辑
- 若
args[1]匹配已注册的自定义命令名,则分发到该命令 - 否则,回退到内置的 clap CLI(
crate::run)
§示例
ⓘ
use sz_rust_cli::{Console, Command, CommandSignature};
let mut console = Console::new();
console.register(Box::new(MyCommand));
console.run(vec!["sz-rust".to_string(), "my:command".to_string()]);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Console
impl !UnwindSafe for Console
impl Freeze for Console
impl Send for Console
impl Sync for Console
impl Unpin for Console
impl UnsafeUnpin for Console
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more