]> git.proxmox.com Git - proxmox.git/commitdiff
proxmox-api/src/cli/format.rs: improve generate_usage_str()
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 15 Jan 2020 13:02:29 +0000 (14:02 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 15 Jan 2020 13:09:34 +0000 (14:09 +0100)
List all arguments, and reduce empty lines.

proxmox-api/src/cli/format.rs
proxmox-api/src/format.rs

index 95ce68d33b0f94e0da7556391c6475f2861a6e75..36f4c19d5708a52316290037595bc93613efbdd3 100644 (file)
@@ -94,21 +94,18 @@ pub fn generate_usage_str(
 
         let type_text = get_schema_type_text(param_schema, ParameterDisplayStyle::Arg);
 
+        let prop_descr =
+            get_property_description(prop, param_schema, ParameterDisplayStyle::Arg, format);
+
         if *optional {
-            if !options.is_empty() {
-                options.push('\n');
-            }
-            options.push_str(&get_property_description(
-                prop,
-                param_schema,
-                ParameterDisplayStyle::Arg,
-                format,
-            ));
+            options.push_str(&prop_descr);
         } else {
             args.push_str(" --");
             args.push_str(prop);
             args.push(' ');
             args.push_str(&type_text);
+
+            arg_descr.push_str(&prop_descr);
         }
 
         done_hash.insert(prop);
@@ -139,9 +136,10 @@ pub fn generate_usage_str(
 
     if !arg_descr.is_empty() {
         text.push_str(&arg_descr);
-        text.push('\n');
     }
+
     if !options.is_empty() {
+        text.push_str("Optional parameters:\n\n");
         text.push_str(&options);
         text.push('\n');
     }
index d012e40898904763e9d0995732348558b1772f08..28d63c2a79f9f0b6a4342e5e6a29fc1e2259bf21 100644 (file)
@@ -137,7 +137,6 @@ pub fn get_property_description(
 
         text.push_str(&wrap_text("", "  ", descr, 80));
         text.push('\n');
-        text.push('\n');
 
         text
     } else {
@@ -152,7 +151,6 @@ pub fn get_property_description(
         text.push('\n');
         text.push_str(&wrap_text(indent, indent, descr, 80));
         text.push('\n');
-        text.push('\n');
 
         text
     }