5 个版本 (3 个重大变更)

使用旧的 Rust 2015

0.3.0 2019年1月22日
0.2.0 2019年1月18日
0.1.1 2018年11月7日
0.1.0 2018年8月6日
0.0.0 2018年6月21日

#507 in 文本处理

Download history 14933/week @ 2024-03-14 10787/week @ 2024-03-21 8636/week @ 2024-03-28 6999/week @ 2024-04-04 5970/week @ 2024-04-11 5504/week @ 2024-04-18 5152/week @ 2024-04-25 4697/week @ 2024-05-02 4148/week @ 2024-05-09 6618/week @ 2024-05-16 11660/week @ 2024-05-23 9145/week @ 2024-05-30 7684/week @ 2024-06-06 5843/week @ 2024-06-13 5437/week @ 2024-06-20 4387/week @ 2024-06-27

每月下载量 24,561
用于 50 个 crate (26 个直接使用)

MIT/Apache

28KB
751

man

crates.io version build status downloads docs.rs docs

使用 roff-rs 生成结构化 man 页面。

用法

use man::prelude::*;

fn main() {
    let page = Manual::new("basic")
        .about("A basic example")
        .author(Author::new("Alice Person").email("[email protected]"))
        .author(Author::new("Bob Human").email("[email protected]"))
        .flag(
            Flag::new()
                .short("-d")
                .long("--debug")
                .help("Enable debug mode"),
        )
        .flag(
            Flag::new()
                .short("-v")
                .long("--verbose")
                .help("Enable verbose mode"),
        )
        .option(
            Opt::new("output")
                .short("-o")
                .long("--output")
                .help("The file path to write output to"),
        )
        .example(
            Example::new()
                .text("run basic in debug mode")
                .command("basic -d")
                .output("Debug Mode: basic will print errors to the console")
            )
        .custom(
            Section::new("usage note")
                .paragraph("This program will overwrite any file currently stored at the output path")
        )
        .render();

    println!("{}", page);
}

运行以下命令预览

$ cargo run > /tmp/app.man; man /tmp/app.man

输出结果

BASIC(1)                                             General Commands Manual                                             BASIC(1)

NAME
       basic - A basic example

SYNOPSIS
       basic [FLAGS] [OPTIONS]

FLAGS
       -d, --debug
              Enable debug mode

       -v, --verbose
              Enable verbose mode

OPTIONS
       -o, --output=output
              The file path to write output to

USAGE NOTE
       This file will overwrite any file currently stored at the output path.

EXIT STATUS
       0      Successful program execution.

       1      Unsuccessful program execution.

       101    The program panicked.

EXAMPLES
       run basic in debug mode
              $ basic -d
              Debug Mode: basic will print errors to the console

AUTHORS
         Alice Person <[email protected]>
         Bob Human <[email protected]>

安装

如果使用 cargo-edit,则使用以下命令安装:

$ cargo add man

否则,通过将依赖项添加到 Cargo.toml 文件的依赖项部分来安装。

许可证

MITApache-2.0

依赖项

~21KB