Skip to content

Commit a1f5d72

Browse files
authored
Sort subcommands automatically in help output (#751)
By default `clap` will display subcommands in `--help` in the order they were added to the `Command`. In our case the order is random due to the split between commands from `progenitor` and custom commands added manually. Set `display_order(0)` on subcommands to allow `clap` to sort them automatically. Before: Commands: experimental certificate disk floating-ip group image instance project current-user ping Ping API policy snapshot system silo ip-pool user utilization Fetch resource utilization for user's current silo vpc auth Login, logout, and get the status of your authentication. docs Generate CLI docs in JSON format completion Generate shell completion scripts for Oxide CLI commands. version Prints version information about the CLI. api Makes an authenticated HTTP request to the Oxide API and prints the response. help Print this message or the help of the given subcommand(s) After: Commands: api Makes an authenticated HTTP request to the Oxide API and prints the response. auth Login, logout, and get the status of your authentication. certificate completion Generate shell completion scripts for Oxide CLI commands. current-user disk docs Generate CLI docs in JSON format experimental floating-ip group image instance ip-pool ping Ping API policy project silo snapshot system user utilization Fetch resource utilization for user's current silo version Prints version information about the CLI. vpc help Print this message or the help of the given subcommand(s)
1 parent bb59581 commit a1f5d72

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cli/src/cli_builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,12 @@ impl CommandExt for Command {
598598
self.subcommand(
599599
Command::new(first.to_owned())
600600
.subcommand_required(true)
601+
.display_order(0)
601602
.add_subcommand(rest, subcmd),
602603
)
603604
}
604605
} else {
605-
let new_subcmd = subcmd.into().name(path.to_owned());
606+
let new_subcmd = subcmd.into().name(path.to_owned()).display_order(0);
606607
let has_subcommand = self.find_subcommand(path).is_some();
607608
if has_subcommand {
608609
self.mut_subcommand(path, |cmd| {

0 commit comments

Comments
 (0)