14 releases

0.3.6 Nov 30, 2024
0.3.5 Jul 30, 2024
0.3.4 Aug 14, 2023
0.3.3 Feb 12, 2023
0.2.1 Nov 23, 2021

#384 in Command-line interface

Download history 2/week @ 2024-08-17 5/week @ 2024-08-31 11/week @ 2024-09-07 7/week @ 2024-09-14 24/week @ 2024-09-21 15/week @ 2024-09-28 3/week @ 2024-10-05 14/week @ 2024-10-12 3/week @ 2024-10-19 19/week @ 2024-11-02 1/week @ 2024-11-09 14/week @ 2024-11-16 7/week @ 2024-11-23 145/week @ 2024-11-30

172 downloads per month
Used in 5 crates (2 directly)

MPL-2.0 license

73KB
2K SLoC

aopt

Generate help message for command line program.

Example

fn display_help<S: Set>(set: &S) -> Result<(), aopt_help::Error> {
    let foot = format!(
        "Create by {} v{}",
        env!("CARGO_PKG_AUTHORS"),
        env!("CARGO_PKG_VERSION")
    );
    let mut app_help = aopt_help::AppHelp::new(
        env!("CARGO_PKG_NAME"),
        env!("CARGO_PKG_DESCRIPTION"),
        &foot,
        aopt_help::prelude::Style::default(),
        std::io::stdout(),
    );
    let global = app_help.global_mut();

    global.add_block(Block::new("option", "[OPTION]", "", "OPTION:", ""))?;
    global.add_block(Block::new("args", "[ARGS]", "", "ARGS:", ""))?;
    for opt in set.iter() {
        if opt.mat_style(Style::Pos) {
            global.add_store(
                "args",
                Store::new(
                    Cow::from(opt.name().as_str()),
                    Cow::from(opt.hint().as_str()),
                    Cow::from(opt.help().as_str()),
                    Cow::from(opt.r#type().to_string()),
                    opt.optional(),
                    true,
                ),
            )?;
        } else if opt.mat_style(Style::Argument)
            || opt.mat_style(Style::Boolean)
            || opt.mat_style(Style::Combined)
        {
            global.add_store(
                "option",
                Store::new(
                    Cow::from(opt.name().as_str()),
                    Cow::from(opt.hint().as_str()),
                    Cow::from(opt.help().as_str()),
                    Cow::from(opt.r#type().to_string()),
                    opt.optional(),
                    false,
                ),
            )?;
        }
    }

    app_help.display(true)?;

    Ok(())
}

More

  • simple-find-file

A simple file search tools, try it using cargo install --path simple-find-file.

  • snowball-follow

Get the follow count of stock in xueqiu.com, try it using cargo install --path snowball-follow

LICENSE

MPL-2.0

Dependencies

~1.5MB
~22K SLoC