pub const COMMAND_STUB: &str = r#"//! {%namespace%}::{%className%} 命令
//!
//! 由 `sz-rust make:command` 生成,对齐 PHP `make:command`。
//! 通过 `Console::register(Box::new({%className%}))` 注册后可被 `sz-rust {%command_name%}` 调用。
use sz_rust_cli::console::{Command, CommandSignature};
use sz_rust_cli::error::CliError;
/// {%className%} 命令
///
/// 对齐 PHP `class {%className%} extends \think\console\Command`。
pub struct {%className%};
impl Command for {%className%} {
/// 命令签名(对齐 PHP `Command::configure()`)
fn signature(&self) -> CommandSignature {
CommandSignature::new(
"{%command_name%}",
"{%className%} 自定义命令",
)
.usage("sz-rust {%command_name%} [options]")
}
/// 执行命令(对齐 PHP `Command::execute(Input $input, Output $output)`)
fn execute(&self, _args: &[String]) -> Result<i32, CliError> {
println!("{%className%} executed");
Ok(0)
}
}
"#;Expand description
Command 模板(对齐 PHP make:command)
PHP 原文生成继承 think\console\Command 的命令类,Rust 生成实现 Command trait 的结构体。