Generate structured man pages using roff-rs.
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"),
)
.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.
AUTHORS
Alice Person <[email protected]>
Bob Human <[email protected]>
If using cargo-edit, install with
$ cargo add man
Otherwise, install by adding to Cargo.toml file's dependency section.
MIT OR Apache-2.0