From 74ecffc8ff34afbfc165aad52e4a45dba64b3305 Mon Sep 17 00:00:00 2001 From: gtema Date: Fri, 8 Mar 2024 15:27:41 +0100 Subject: [PATCH] feat: visually separate global options in help message use claps `next_help_heading` and `display_order` to visually separate global options from operation options. --- doc/src/osc.md | 4 ++-- openstack_cli/src/cli.rs | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/src/osc.md b/doc/src/osc.md index 605484248..68abaa6e0 100644 --- a/doc/src/osc.md +++ b/doc/src/osc.md @@ -460,14 +460,14 @@ OpenStack client rewritten in Rust - `json`: Json output - `wide`: - Wide (Human readable table with extra attributes). Note: this has effect only in list operations) + Wide (Human readable table with extra attributes). Note: this has effect only in list operations * `-f`, `--fields ` — Fields to return in the output (only in normal and wide mode) -* `-v`, `--verbose` — Verbosity level. Repeat to increase level * `-p`, `--pretty` — Pretty print the output Possible values: `true`, `false` +* `-v`, `--verbose` — Verbosity level. Repeat to increase level diff --git a/openstack_cli/src/cli.rs b/openstack_cli/src/cli.rs index ae8db25e0..32bfc7624 100644 --- a/openstack_cli/src/cli.rs +++ b/openstack_cli/src/cli.rs @@ -57,26 +57,27 @@ pub struct Cli { /// Global CLI options #[derive(Args)] +#[command(next_display_order = 900, next_help_heading = "Global options")] pub struct GlobalOpts { /// Name reference to the clouds.yaml entry for the cloud configuration - #[arg(long, env = "OS_CLOUD", global = true)] + #[arg(long, env = "OS_CLOUD", global = true, display_order = 900)] pub os_cloud: Option, /// Output format - #[arg(short, long, global = true, value_enum)] + #[arg(short, long, global = true, value_enum, display_order = 910)] pub output: Option, /// Fields to return in the output (only in normal and wide mode) - #[arg(short, long, global=true, action=clap::ArgAction::Append)] + #[arg(short, long, global=true, action=clap::ArgAction::Append, display_order = 910)] pub fields: Vec, - /// Verbosity level. Repeat to increase level. - #[arg(short, long, global=true, action = clap::ArgAction::Count)] - pub verbose: u8, - /// Pretty print the output - #[arg(short, long, global=true, action = clap::ArgAction::SetTrue)] + #[arg(short, long, global=true, action = clap::ArgAction::SetTrue, display_order = 910)] pub pretty: bool, + + /// Verbosity level. Repeat to increase level. + #[arg(short, long, global=true, action = clap::ArgAction::Count, display_order = 920)] + pub verbose: u8, } /// Output format @@ -85,7 +86,7 @@ pub enum OutputFormat { /// Json output Json, /// Wide (Human readable table with extra attributes). Note: this has - /// effect only in list operations) + /// effect only in list operations Wide, }