Expand description
SZ-Rust CLI — 命令行工具
替代 PHP think 命令,借鉴 Laravel Artisan 风格。
§PHP 对齐
本包对齐 PHP ThinkPHP 6 think 命令体系:
php think make:model→sz-rust make:modelphp think make:controller→sz-rust make:controllerphp think make:migration→sz-rust make:migration(Phinx 风格)php think migrate→sz-rust migratephp think migrate:status→sz-rust migrate:statusphp think route:list→sz-rust route:listphp think cache:clear→sz-rust cache:clear
§模块结构
| 模块 | 功能 |
|---|---|
cli | clap 命令定义(Cli / Commands / Options) |
console | 自定义命令注册与分发(对齐 PHP think\console\Console) |
cmd::make | make:* 代码生成命令 |
cmd::migrate | migrate / migrate:status 迁移命令 |
cmd::route | route:list 路由列表命令 |
cmd::cache | cache:clear 缓存清理命令 |
cmd::scheduler | scheduler:* 调度器命令 |
error | CLI 错误类型 |
stubs | 代码生成模板(对齐 PHP make/stubs) |
§R5 硬约束
- R5-48:
make:model生成 Model 骨架代码对齐 PHPthink\console\command\make\Model - R5-49:
make:controller生成 Controller 骨架代码对齐 PHPthink\console\command\make\Controller - R5-50:
migrate:status显示迁移进度对齐 PHPthink migrate:status - R5-51:
cache:clear清空缓存对齐 PHPthink cache:clear
Re-exports§
pub use cli::Cli;pub use cli::Command as CliCommand;pub use console::Command;pub use console::CommandSignature;pub use console::Console;pub use error::CliError;
Modules§
- cli
- CLI 命令定义 — 基于 clap derive
- cmd
- 命令模块 — 各命令的实现
- console
- Console 模块 — 自定义命令注册与分发
- error
- CLI 错误类型
- stubs
- 代码生成模板 — 对齐 PHP
think\console\command\make\stubs\*.stub
Functions§
- run
- 运行 CLI(入口函数)