Skip to content

Commit

Permalink
Merge branch 'fix_completion-bin-name'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 13, 2023
2 parents 1955a57 + 7f2bc08 commit fb81093
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,13 +1221,16 @@ pub fn main() -> Result<()> {
},
Subcommands::Completions { shell, out_dir } => {
let mut app = Args::command();

let shell = shell
.or_else(clap_complete::Shell::from_env)
.ok_or_else(|| anyhow!("The shell could not be derived from the environment"))?;

let bin_name = app.get_name().to_owned();
if let Some(out_dir) = out_dir {
clap_complete::generate_to(shell, &mut app, env!("CARGO_PKG_NAME"), &out_dir)?;
clap_complete::generate_to(shell, &mut app, bin_name, &out_dir)?;
} else {
clap_complete::generate(shell, &mut app, env!("CARGO_PKG_NAME"), &mut std::io::stdout());
clap_complete::generate(shell, &mut app, bin_name, &mut std::io::stdout());
}
Ok(())
}
Expand Down

0 comments on commit fb81093

Please sign in to comment.