1use std::io;
2
3use anyhow::Result;
4use clap::CommandFactory;
5use clap_complete::Shell;
6
7use crate::cli::Cli;
8
9const BASH_GIT_SHIM: &str = r#"
16_git_stk() {
17 local cur prev
18 COMP_WORDS=("git-stk" "${COMP_WORDS[@]:2}")
19 COMP_CWORD=$((COMP_CWORD - 1))
20 cur="${COMP_WORDS[COMP_CWORD]}"
21 prev="${COMP_WORDS[COMP_CWORD - 1]}"
22 _git-stk git-stk "$cur" "$prev"
23}
24"#;
25
26pub fn print(shell: Shell) -> Result<()> {
27 let mut command = Cli::command();
28 clap_complete::generate(shell, &mut command, "git-stk", &mut io::stdout());
29
30 if shell == Shell::Bash {
31 print!("{BASH_GIT_SHIM}");
32 }
33
34 Ok(())
35}