st_cli/
lib.rs

1use crate::public::RunTrait;
2use structopt::StructOpt;
3
4pub(crate) mod plugins;
5pub(crate) mod public;
6pub(crate) mod run_cmd;
7pub(crate) mod sub_cmd;
8pub(crate) mod utils;
9
10#[derive(Debug, StructOpt)]
11#[structopt(name = "st")]
12pub enum StCli {
13    /// 编译
14    ///
15    /// Rust 项目 默认使用: cargo build
16    /// npm 项目 不支持
17    /// poetry 项目 默认使用: poetry build 打包
18    Build,
19    /// 清理开发环境
20    ///
21    /// Rust 使用 cargo clean
22    ///
23    /// npm 清理缓存 npm cache clean
24    ///
25    /// poetry 不支持
26    ///
27    Clean,
28    /// 格式化代码
29    ///
30    /// 当前支持
31    ///
32    /// Python poetry 的项目 [需要安装 black]
33    ///
34    /// Rust 项目 cargo fmt
35    Format,
36    /// 代码检测
37    ///
38    /// Rust 使用 Cargo clippy
39    ///
40    /// Python 使用 pylama
41    Lint,
42    /// 检测依赖是否有新版
43    ///
44    /// Rust 使用 Cargo
45    ///
46    /// Python 使用 Poetry
47    Outdated,
48    /// 运行
49    ///
50    /// Rust 使用 cargo run
51    ///
52    /// Python Django 项目使用 django-admin runserver
53    Run,
54    /// 升级依赖版本
55    ///
56    /// Rust 使用 cargo
57    ///
58    /// Python 使用 Poetry
59    Update,
60    /// 测试
61    ///
62    /// Rust 语言使用 cargo test
63    ///
64    /// Python 使用 pytest
65    Test,
66    /// 同步依赖
67    Sync,
68    /// 锁定依赖
69    ///
70    /// 锁定当前的依赖
71    ///
72    /// Python 使用 Poetry
73    Lock,
74    /// 本地安装
75    ///
76    /// 本地安装当前的软件
77    /// Rust 使用 cargo install --path .
78    Install,
79    /// 发布
80    ///
81    /// Python 使用 Poetry 发布到 Pypi
82    ///
83    /// todo Rust 使用 cargo 发布到 Crates
84    Publish,
85    /// 提升版本
86    Bump(public::bump::Bump),
87    /// django 子命令
88    Django(sub_cmd::DjangoSubCmd),
89}
90
91impl StCli {
92    pub fn run(&self) {
93        match self {
94            StCli::Build => run_cmd::run_build_cmd(),
95            StCli::Clean => run_cmd::run_clean_cmd(),
96            StCli::Format => run_cmd::run_format_cmd(),
97            StCli::Lint => run_cmd::run_lint_cmd(),
98            StCli::Outdated => run_cmd::run_outdated_cmd(),
99            StCli::Run => run_cmd::run_run_cmd(),
100            StCli::Update => run_cmd::run_update_cmd(),
101            StCli::Test => run_cmd::run_test_cmd(),
102            StCli::Sync => run_cmd::run_sync_cmd(),
103            StCli::Lock => run_cmd::run_lock_cmd(),
104            StCli::Install => run_cmd::run_install_cmd(),
105            StCli::Publish => run_cmd::run_publish_cmd(),
106            StCli::Bump(bump) => run_cmd::run_bump_cmd(bump),
107            StCli::Django(cmd) => cmd.run(),
108        }
109    }
110}