diff options
Diffstat (limited to '')
| -rw-r--r-- | src/cli.rs | 18 |
1 files changed, 16 insertions, 2 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | use crate::config::Config; | 1 | use crate::config::Config; |
| 2 | use crate::database::Database; | 2 | use crate::database::Database; |
| 3 | use clap::{CommandFactory, Parser, Subcommand}; | 3 | use clap::{Command, CommandFactory, Parser, Subcommand}; |
| 4 | use clap_complete::{Shell, generate}; | 4 | use clap_complete::{Shell, generate}; |
| 5 | use std::path::PathBuf; | 5 | use std::path::PathBuf; |
| 6 | 6 | ||
| @@ -218,7 +218,21 @@ impl Cli { | |||
| 218 | } | 218 | } |
| 219 | } | 219 | } |
| 220 | Commands::Completions { shell } => { | 220 | Commands::Completions { shell } => { |
| 221 | let mut cmd = Cli::command(); | 221 | let full = Cli::command(); |
| 222 | let subcommands: Vec<Command> = full | ||
| 223 | .get_subcommands() | ||
| 224 | .filter(|s| s.get_name() != "completions") | ||
| 225 | .cloned() | ||
| 226 | .collect(); | ||
| 227 | let cmd_name = full.get_name().to_string(); | ||
| 228 | let about = full.get_about().cloned(); | ||
| 229 | let mut cmd = Command::new(cmd_name).infer_long_args(true); | ||
| 230 | if let Some(a) = about { | ||
| 231 | cmd = cmd.about(a); | ||
| 232 | } | ||
| 233 | for sc in subcommands { | ||
| 234 | cmd = cmd.subcommand(sc); | ||
| 235 | } | ||
| 222 | if let Some(s) = shell { | 236 | if let Some(s) = shell { |
| 223 | let shell = match s.as_str() { | 237 | let shell = match s.as_str() { |
| 224 | "bash" => Shell::Bash, | 238 | "bash" => Shell::Bash, |
