2022-02-12 03:48:29 +00:00
|
|
|
use clap::{arg, Command};
|
2022-02-08 02:19:59 +00:00
|
|
|
use clap_mangen::Man;
|
2022-01-28 20:55:55 +00:00
|
|
|
use std::io;
|
|
|
|
|
|
|
|
// Run this example as `cargo run --example man | man -l -`.
|
|
|
|
|
|
|
|
fn main() -> Result<(), std::io::Error> {
|
2022-02-14 21:47:20 +00:00
|
|
|
let cmd = Command::new("myapp")
|
2022-01-28 20:55:55 +00:00
|
|
|
.version("1.0")
|
|
|
|
.author("Kevin K. <kbknapp@gmail.com>:Ola Nordmann <old@nordmann.no>")
|
|
|
|
.about("Does awesome things")
|
|
|
|
.long_about(
|
|
|
|
"With a longer description to help clarify some things.
|
|
|
|
|
|
|
|
And a few newlines.",
|
|
|
|
)
|
|
|
|
.after_help("This is an extra section added to the end of the manpage.")
|
|
|
|
.after_long_help("With even more text added.")
|
|
|
|
.arg(
|
|
|
|
arg!(-c --config <FILE> "Sets a custom config file")
|
|
|
|
.long_help("Some more text about how to set a custom config file")
|
|
|
|
.required(false)
|
|
|
|
.takes_value(true)
|
|
|
|
.default_value("config.toml")
|
|
|
|
.env("CONFIG_FILE"),
|
|
|
|
)
|
|
|
|
.arg(arg!([output] "Sets an output file").default_value("result.txt"))
|
|
|
|
.arg(
|
|
|
|
arg!(-d --debug ... "Turn debugging information on")
|
|
|
|
.env("DEBUG_ON")
|
|
|
|
.hide_env(true),
|
|
|
|
)
|
|
|
|
.subcommand(
|
2022-02-12 03:48:29 +00:00
|
|
|
Command::new("test")
|
2022-01-28 20:55:55 +00:00
|
|
|
.about("does testing things")
|
|
|
|
.arg(arg!(-l --list "Lists test values")),
|
|
|
|
);
|
|
|
|
|
2022-02-14 21:47:20 +00:00
|
|
|
Man::new(cmd).render(&mut io::stdout())
|
2022-01-28 20:55:55 +00:00
|
|
|
}
|