Skip to content

Commit 012625f

Browse files
committed
Sort commands for CLI generation
Iterating over the commands directly from the hash-map is non-deterministic. Sort the commands by name before doing that to have a deterministic interface.
1 parent 9771de2 commit 012625f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cli/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ impl Registry {
4848
.action(clap::ArgAction::SetTrue)
4949
.global(true));
5050

51-
for cmd in self.commands.values() {
51+
let mut cmds: Vec<_> = self.commands.values().collect();
52+
cmds.sort_by_key(|c| c.name());
53+
54+
for cmd in cmds {
5255
app = app.subcommand(cmd.build());
5356
}
5457

0 commit comments

Comments
 (0)