Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subcommand to generate completions, remove build.rs #369

Merged
merged 2 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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