• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use clap::{arg, Command};
2 use clap_mangen::Man;
3 use std::io;
4 
5 // Run this example as `cargo run --example man | man -l -`.
6 
main() -> Result<(), std::io::Error>7 fn main() -> Result<(), std::io::Error> {
8     let cmd = Command::new("myapp")
9         .version("1.0")
10         .author("Kevin K. <kbknapp@gmail.com>:Ola Nordmann <old@nordmann.no>")
11         .about("Does awesome things")
12         .long_about(
13             "With a longer description to help clarify some things.
14 
15 And a few newlines.",
16         )
17         .after_help("This is an extra section added to the end of the manpage.")
18         .after_long_help("With even more text added.")
19         .arg(
20             arg!(-c --config <FILE> "Sets a custom config file")
21                 .long_help("Some more text about how to set a custom config file")
22                 .default_value("config.toml")
23                 .env("CONFIG_FILE"),
24         )
25         .arg(arg!([output] "Sets an output file").default_value("result.txt"))
26         .arg(
27             arg!(-d --debug ... "Turn debugging information on")
28                 .env("DEBUG_ON")
29                 .hide_env(true),
30         )
31         .subcommand(
32             Command::new("test")
33                 .about("does testing things")
34                 .arg(arg!(-l --list "Lists test values")),
35         );
36 
37     Man::new(cmd).render(&mut io::stdout())
38 }
39