From d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 11 Feb 2020 16:25:09 +0000 Subject: crosvm: improve crosvm run --help output The specifiers and descriptions for crosvm options are just too long to fit into a table. Options were already eclipsing the widths of the table cells, and sizing them correctly just made the table infeasibly wide. So, instead, just print out paragraphs for each option, and stop trying to fit things into a table. Use this opportunity to add some spacing and make key value lists within option descriptions more readable. Also, make formatting consistent. Consistent spacing between sentences, consistent default output, etc. --- src/argument.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/argument.rs') diff --git a/src/argument.rs b/src/argument.rs index f59d503..9ef9d4d 100644 --- a/src/argument.rs +++ b/src/argument.rs @@ -381,28 +381,34 @@ pub fn print_help(program_name: &str, required_arg: &str, args: &[Argument]) { return; } println!("Argument{}:", if args.len() > 1 { "s" } else { "" }); + for arg in args { - match arg.short { - Some(s) => print!(" -{}, ", s), - None => print!(" "), + println!(); + + if let Some(s) = arg.short { + print!(" -{}", s); + if !arg.long.is_empty() { + print!(","); + } } - if arg.long.is_empty() { - print!(" "); - } else { - print!("--"); + + print!(" "); + + if !arg.long.is_empty() { + print!("--{}", arg.long); } - print!("{:<12}", arg.long); + if let Some(v) = arg.value { - if arg.long.is_empty() { - print!(" "); - } else { + if !arg.long.is_empty() { print!("="); } - print!("{:<10}", v); - } else { - print!("{:<11}", ""); + print!("{}", v); + } + + println!(); + for line in arg.help.lines() { + println!(" {}", line); } - println!("{}", arg.help); } } -- cgit 1.4.1