soroban_cli/commands/
completion.rs1use clap::{arg, CommandFactory, Parser};
2use clap_complete::{generate, Shell};
3use std::io;
4
5use crate::commands::Root;
6
7pub const LONG_ABOUT: &str = "\
8Print shell completion code for the specified shell
9
10Ensure the completion package for your shell is installed, e.g. bash-completion for bash.
11
12To enable autocomplete in the current bash shell, run: `source <(stellar completion --shell bash)`
13
14To enable autocomplete permanently, run: `echo \"source <(stellar completion --shell bash)\" >> ~/.bashrc`
15";
16
17#[derive(Parser, Debug, Clone)]
18#[group(skip)]
19pub struct Cmd {
20 #[arg(long, value_enum)]
22 shell: Shell,
23}
24
25impl Cmd {
26 pub fn run(&self) {
27 let cmd = &mut Root::command();
28 generate(self.shell, cmd, "stellar", &mut io::stdout());
29 }
30}