summary refs log tree commit diff
path: root/src/argument.rs
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-02-11 16:25:09 +0000
committerAlyssa Ross <hi@alyssa.is>2020-03-09 01:53:51 +0000
commitd6e0b965a47dc1b1a77d771d39c2a50ca7b9f345 (patch)
tree3a09dee6078b0a6cd7b453080d63ebe55bb6a76a /src/argument.rs
parenta365d1c3406b448c20dac93466d93d1df9755893 (diff)
downloadcrosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar.gz
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar.bz2
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar.lz
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar.xz
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.tar.zst
crosvm-d6e0b965a47dc1b1a77d771d39c2a50ca7b9f345.zip
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.
Diffstat (limited to 'src/argument.rs')
-rw-r--r--src/argument.rs36
1 files changed, 21 insertions, 15 deletions
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);
     }
 }