pub fn assert_sorted(cmd: &Command)Expand description
Validates that subcommands and arguments are sorted correctly.
This checks:
- Subcommands are sorted alphabetically
- Arguments are grouped and sorted by type:
- Positional arguments (order not enforced)
- Flags with short options (alphabetically by short option)
- Long-only flags (alphabetically)
Recursively validates all subcommands.
§Panics
Panics if subcommands or arguments are not properly sorted.
§Example
use clap::{Command, Arg};
let cmd = Command::new("mycli")
.arg(Arg::new("file")) // Positional
.arg(Arg::new("output").short('o').long("output")) // Short flag
.arg(Arg::new("config").long("config")); // Long-only flag
clap_sort::assert_sorted(&cmd);