From b5872054f641bb417bd1ffc6a9ded1d95181b943 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 26 May 2026 07:01:40 +0200 Subject: no need to ship completions anymore! --- src/cli.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index f9a3c6f..4590f57 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,6 @@ use crate::config::Config; use crate::database::Database; -use clap::{CommandFactory, Parser, Subcommand}; +use clap::{Command, CommandFactory, Parser, Subcommand}; use clap_complete::{Shell, generate}; use std::path::PathBuf; @@ -218,7 +218,21 @@ impl Cli { } } Commands::Completions { shell } => { - let mut cmd = Cli::command(); + let full = Cli::command(); + let subcommands: Vec = full + .get_subcommands() + .filter(|s| s.get_name() != "completions") + .cloned() + .collect(); + let cmd_name = full.get_name().to_string(); + let about = full.get_about().cloned(); + let mut cmd = Command::new(cmd_name).infer_long_args(true); + if let Some(a) = about { + cmd = cmd.about(a); + } + for sc in subcommands { + cmd = cmd.subcommand(sc); + } if let Some(s) = shell { let shell = match s.as_str() { "bash" => Shell::Bash, -- cgit v1.2.3