cok

Crates.iocok
lib.rscok
version0.1.13
sourcesrc
created_at2022-10-09 00:52:01.488885
updated_at2023-09-09 14:48:22.619697
descriptionA simple to use, efficient, Command Line Argument Parser
homepage
repositoryhttps://gitlab.com/andrew_ryan/cok
max_upload_size
id683812
size16,214
zinso (zinso)

documentation

https://docs.rs/cok

README

A simple to use, efficient, Command Line Argument Parser

Crates.io Rust license

Example

create cli.json

{
    "name":"cargo",
    "version":"1.0.0",
    "authors":["andrew <dnrops@anonymous.com>","ryan <rysn@gmail.com>"],
    "description":"Rust's package manager",
    "options":[
        {
            "name":"--version",
            "short":"V",
            "description":"Print version info and exit"
        },
        {
            "name":"--offline",
            "description":"Run without accessing the network"
        }
    ],
    "commands":[
        {
            "name":"build",
            "short":"b",
            "description":"Compile the current package"
        },
        {
            "name":"check",
            "short":"c",
            "description":"Analyze the current package and report errors, but don't build object files"
        },
        {
            "name":"clean",
            "description":"Remove the target directory"
        },
        {
            "name":"new",
            "description":"Create a new cargo package"
        },
        {
            "name":"add",
            "description":"Add dependencies to a manifest file"
        }
    ]
}
cargo add cok

main.rs

fn main() {
    use cok::Cli;
    let json = include_str!("../cli.json");
    let cli = Cli::new(json);
    let args = cli.args();
    if args.len() !=3{
        cli.print_help()
    }
}

a simple cli

cargo 1.0.0
andrew <dnrops@anonymous.com>,ryan <rysn@gmail.com>
Rust's package manager

Usage: cargo [OPTIONS] [COMMAND]

Options:
cargo   build, b        Compile the current package
cargo   check, c        Analyze the current package and report errors, but don't build object files
cargo   clean           Remove the target directory
cargo   new             Create a new cargo package
cargo   add             Add dependencies to a manifest file

Commands:
cargo   build, b        Compile the current package
cargo   check, c        Analyze the current package and report errors, but don't build object files
cargo   clean           Remove the target directory
cargo   new             Create a new cargo package
cargo   add             Add dependencies to a manifest file
cargo   -h --help       Prints help information
Commit count: 15

cargo fmt