From d254bbd4cd8b37870eb7dfe446d765fe8a1bfb7d Mon Sep 17 00:00:00 2001 From: Pagwin Date: Sun, 25 Sep 2022 16:25:19 -0400 Subject: [PATCH] made things mildly less effiecient so I could print pretty help --- Cargo.toml | 2 +- src/main.rs | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e22615..347ae5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ppi" -version = "1.1.0" +version = "1.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 98f8de7..e170815 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,16 +68,7 @@ fn main() -> Result<(),Errors> { .author(clap::crate_authors!()) .subcommands(skeletons.keys().map(|v|Command::new(v).arg(Arg::new("output_dir").takes_value(true).action(clap::ArgAction::Append)))) .subcommands(scripts.keys().map(|v|Command::new(v).arg(Arg::new("script_args").takes_value(true)))); - let mut short_help = String::new(); - let mut long_help = String::new(); - { - let mut short_help_buf = Vec::new(); - let mut long_help_buf = Vec::new(); - program.write_help(&mut Cursor::new(&mut short_help_buf))?; - program.write_help(&mut Cursor::new(&mut long_help_buf))?; - short_help_buf.as_slice().read_to_string(&mut short_help)?; - long_help_buf.as_slice().read_to_string(&mut long_help)?; - } + let mut prog_copy = program.clone(); program.build(); let matches = program.get_matches(); for (skelly_name, (skelly_src, skelly_branch)) in skeletons { @@ -177,7 +168,7 @@ fn main() -> Result<(),Errors> { std::process::exit(std::process::Command::new(script.1).args(sub.get_many::("script_args").map(Iterator::collect).unwrap_or(Vec::new())).spawn()?.wait()?.code().ok_or(Errors::Unknown)?); } } - println!("{}", short_help); + prog_copy.print_help()?; Ok(()) } #[derive(Debug)]