Skip to content

Commit

Permalink
imp(Completions): allows multiple completions to be built by namespac…
Browse files Browse the repository at this point in the history
…ing with bin name

Completions are now written `<bin>_<shell>.<ext>` vice the old, `<shell>.<ext>`
  • Loading branch information
kbknapp committed Jul 2, 2016
1 parent f10375e commit 57484b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ impl<'a, 'b> App<'a, 'b> {
/// ```
/// Now, once we combile there will be a `bash.sh` file in the directory. Assuming we compiled
/// with debug mode, it would be somewhere similar to
/// `<project>/target/debug/build/myapp-<hash>/out/bash.sh`
/// `<project>/target/debug/build/myapp-<hash>/out/myapp_bash.sh`
pub fn gen_completions<T: Into<OsString>, S: Into<String>>(&mut self, bin_name: S, for_shell: Shell, out_dir: T) {
self.p.meta.bin_name = Some(bin_name.into());
self.p.gen_completions(for_shell, out_dir.into());
Expand Down
2 changes: 1 addition & 1 deletion src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a, 'b> ComplGen<'a, 'b> {
use std::error::Error;
let out_dir = PathBuf::from(&self.out_dir);

let mut file = match File::create(out_dir.join("bash.sh")) {
let mut file = match File::create(out_dir.join(format!("{}_bash.sh", &*self.p.meta.bin_name.as_ref().unwrap()))) {
Err(why) => panic!("couldn't create bash completion file: {}",
why.description()),
Ok(file) => file,
Expand Down

0 comments on commit 57484b2

Please sign in to comment.