mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
#![allow(unused)]
|
|
extern crate clap;
|
|
|
|
use clap::IntoApp;
|
|
|
|
pub fn get_help<T: IntoApp>() -> String {
|
|
let mut output = Vec::new();
|
|
<T as IntoApp>::into_app()
|
|
.write_help(&mut output)
|
|
.unwrap();
|
|
let output = String::from_utf8(output).unwrap();
|
|
|
|
eprintln!("\n%%% HELP %%%:=====\n{}\n=====\n", output);
|
|
eprintln!("\n%%% HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
|
|
|
|
output
|
|
}
|
|
|
|
pub fn get_long_help<T: IntoApp>() -> String {
|
|
let mut output = Vec::new();
|
|
<T as IntoApp>::into_app()
|
|
.write_long_help(&mut output)
|
|
.unwrap();
|
|
let output = String::from_utf8(output).unwrap();
|
|
|
|
eprintln!("\n%%% LONG_HELP %%%:=====\n{}\n=====\n", output);
|
|
eprintln!("\n%%% LONG_HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
|
|
|
|
output
|
|
}
|
|
|
|
pub fn get_subcommand_long_help<T: IntoApp>(subcmd: &str) -> String {
|
|
let output = <T as IntoApp>::into_app()
|
|
.try_get_matches_from(vec!["test", subcmd, "--help"])
|
|
.expect_err("")
|
|
.message;
|
|
|
|
eprintln!(
|
|
"\n%%% SUBCOMMAND `{}` HELP %%%:=====\n{}\n=====\n",
|
|
subcmd, output
|
|
);
|
|
eprintln!(
|
|
"\n%%% SUBCOMMAND `{}` HELP (DEBUG) %%%:=====\n{:?}\n=====\n",
|
|
subcmd, output
|
|
);
|
|
|
|
output
|
|
}
|