use clap::{CommandFactory, Parser, Subcommand}; #[derive(Parser)] struct Cli { #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Generate shell completions Completions { /// The shell to generate the completions for #[arg(value_enum)] shell: clap_complete_command::Shell, }, } fn main() { let cli = Cli::parse(); match cli.command { Commands::Completions { shell } => { shell.generate(&mut Cli::command(), &mut std::io::stdout()); } } }