5 releases (3 breaking)

Uses old Rust 2015

0.3.0 Jan 22, 2019
0.2.0 Jan 18, 2019
0.1.1 Nov 7, 2018
0.1.0 Aug 6, 2018
0.0.0 Jun 21, 2018

#138 in Development tools

Download history 1871/week @ 2021-10-03 2893/week @ 2021-10-10 2789/week @ 2021-10-17 2272/week @ 2021-10-24 2119/week @ 2021-10-31 1994/week @ 2021-11-07 2421/week @ 2021-11-14 1791/week @ 2021-11-21 2225/week @ 2021-11-28 2366/week @ 2021-12-05 2327/week @ 2021-12-12 1640/week @ 2021-12-19 1737/week @ 2021-12-26 1318/week @ 2022-01-02 1798/week @ 2022-01-09 1910/week @ 2022-01-16

6,942 downloads per month
Used in 32 crates (23 directly)

MIT/Apache

28KB
751 lines

man

crates.io version build status downloads docs.rs docs

Generate structured man pages using roff-rs.

Usage

use man::prelude::*;

fn main() {
    let page = Manual::new("basic")
        .about("A basic example")
        .author(Author::new("Alice Person").email("alice@person.com"))
        .author(Author::new("Bob Human").email("bob@human.com"))
        .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);
}

Preview by running:

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

Which outputs:

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 <alice@person.com>
         Bob Human <bob@human.com>

Installation

If using cargo-edit, install with

$ cargo add man

Otherwise, install by adding to Cargo.toml file's dependency section.

License

MIT OR Apache-2.0

Dependencies

~19KB

†YG\