Skip to content

Commit

Permalink
Merge pull request #369 from matthiasbeyer/clap-generate-shellcompletion
Browse files Browse the repository at this point in the history
Add subcommand to generate completions, remove build.rs
  • Loading branch information
a-kenji authored Apr 25, 2021
2 parents b3eb9f1 + 4942968 commit d89e3e9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 247 deletions.
90 changes: 0 additions & 90 deletions assets/completions/_zellij

This file was deleted.

117 changes: 0 additions & 117 deletions assets/completions/zellij.bash

This file was deleted.

17 changes: 0 additions & 17 deletions assets/completions/zellij.fish

This file was deleted.

23 changes: 0 additions & 23 deletions build.rs

This file was deleted.

3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ pub enum ConfigCli {
/// Disables loading of configuration file at default location
clean: bool,
},

#[structopt(name = "generate-completion")]
GenerateCompletion { shell: String },
}
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ pub fn main() {
let mut stream = UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap();
let api_command = bincode::serialize(&ApiCommand::OpenFile(file_to_open)).unwrap();
stream.write_all(&api_command).unwrap();
} else if let Some(crate::cli::ConfigCli::GenerateCompletion { shell }) = opts.option {
let shell = match shell.as_ref() {
"bash" => structopt::clap::Shell::Bash,
"fish" => structopt::clap::Shell::Fish,
"zsh" => structopt::clap::Shell::Zsh,
"powerShell" => structopt::clap::Shell::PowerShell,
"elvish" => structopt::clap::Shell::Elvish,
other => {
eprintln!("Unsupported shell: {}", other);
std::process::exit(1);
}
};
let mut out = std::io::stdout();
CliArgs::clap().gen_completions_to("zellij", shell, &mut out);
} else {
let os_input = get_os_input();
atomic_create_dir(ZELLIJ_TMP_DIR).unwrap();
Expand Down

0 comments on commit d89e3e9

Please sign in to comment.