-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8869d2f
commit 405f51c
Showing
5 changed files
with
78 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#![allow(unused)] | ||
|
||
use structopt::StructOpt; | ||
|
||
pub fn get_help<T: StructOpt>() -> String { | ||
let mut output = Vec::new(); | ||
<T as StructOpt>::clap().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: StructOpt>() -> String { | ||
let mut output = Vec::new(); | ||
<T as StructOpt>::clap() | ||
.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: StructOpt>(subcmd: &str) -> String { | ||
let output = <T as StructOpt>::clap() | ||
.get_matches_from_safe(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 | ||
} |