1 #![allow(unused)]
2
3 use structopt::StructOpt;
4
get_help<T: StructOpt>() -> String5 pub fn get_help<T: StructOpt>() -> String {
6 let mut output = Vec::new();
7 <T as StructOpt>::clap().write_help(&mut output).unwrap();
8 let output = String::from_utf8(output).unwrap();
9
10 eprintln!("\n%%% HELP %%%:=====\n{}\n=====\n", output);
11 eprintln!("\n%%% HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
12
13 output
14 }
15
get_long_help<T: StructOpt>() -> String16 pub fn get_long_help<T: StructOpt>() -> String {
17 let mut output = Vec::new();
18 <T as StructOpt>::clap()
19 .write_long_help(&mut output)
20 .unwrap();
21 let output = String::from_utf8(output).unwrap();
22
23 eprintln!("\n%%% LONG_HELP %%%:=====\n{}\n=====\n", output);
24 eprintln!("\n%%% LONG_HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
25
26 output
27 }
28
get_subcommand_long_help<T: StructOpt>(subcmd: &str) -> String29 pub fn get_subcommand_long_help<T: StructOpt>(subcmd: &str) -> String {
30 let output = <T as StructOpt>::clap()
31 .get_matches_from_safe(vec!["test", subcmd, "--help"])
32 .expect_err("")
33 .message;
34
35 eprintln!(
36 "\n%%% SUBCOMMAND `{}` HELP %%%:=====\n{}\n=====\n",
37 subcmd, output
38 );
39 eprintln!(
40 "\n%%% SUBCOMMAND `{}` HELP (DEBUG) %%%:=====\n{:?}\n=====\n",
41 subcmd, output
42 );
43
44 output
45 }
46