#cmd #start #language #command-line-tool #learning #cargo #uymas #文档

build uymas_cli

the fast and minimal dependency development tool for rust language

6 stable releases

new 2.2.1 Jun 17, 2025
2.2.0 Mar 24, 2024
2.1.0 Jun 8, 2023
2.0.2 Nov 14, 2022
2.0.0 Oct 30, 2022

#166 in Build Utils

Download history 2/week @ 2025-03-14 9/week @ 2025-05-09 95/week @ 2025-06-13

95 downloads per month

MIT license

46KB
1K SLoC

cli

2022年10月30日 星期日

Joshua Conero

命令行语法规则,用于快速开发命令行程序。

起步

基本代码示例

use cli::cmd::{Cmd, CmdRunOs};

fn main() {
    let mut app = Cmd::new();

    // 默认引用
    app.empty(|args| {
        if args.contain_opts(vec!["version", "v"]) {
            println!("v0.1.0-20240324");
            return;
        }
        println!("Hello world, Uymas Cli lib.")
    });

    // 命令不存在
    app.un_found(|args| {
        println!("Error: {} 命令不存在!", args.command);
    });

    // 注册命令
    app.register("conero", |_| {
        println!("Hello, conero");
    });

    // 注册多命令
    app.registers(vec!["test", "t"], |_| {
        println!("注册命令集别名");
        println!();
        println!("Test, try do test ya!");
    });

    // 运行命令行
    app.run();
}

命令行规则

# 如命令:
# test 表命令
# version, x, y, z 表选项
uymas test --version -xyz

No runtime deps