vdev/commands/complete.rs
1use anyhow::Result;
2use clap::{Args, CommandFactory};
3use clap_complete::{generate, Shell};
4use std::io;
5
6use super::Cli as RootCli;
7
8/// Display the completion file for a given shell
9#[derive(Args, Debug)]
10#[command()]
11pub struct Cli {
12 #[arg(value_enum)]
13 shell: Shell,
14}
15
16impl Cli {
17 pub fn exec(self) -> Result<()> {
18 let mut cmd = RootCli::command();
19 let bin_name = cmd.get_name().to_string();
20 generate(self.shell, &mut cmd, bin_name, &mut io::stdout());
21
22 Ok(())
23 }
24}