diff options
| author | a-kenji <aks.kenji@protonmail.com> | 2021-04-25 17:41:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-25 17:41:44 +0200 |
| commit | d89e3e9e697a675b1a1d186dad1ea673ae9a199a (patch) | |
| tree | 809c8da46a25c87b36fe8d20ffba40b62f36eff5 /src | |
| parent | Merge pull request #356 from zellij-org/add-auto-release (diff) | |
| parent | fixup! Add subcommand to generate completions (diff) | |
| download | sl0ppij-d89e3e9e697a675b1a1d186dad1ea673ae9a199a.tar.gz sl0ppij-d89e3e9e697a675b1a1d186dad1ea673ae9a199a.tar.xz sl0ppij-d89e3e9e697a675b1a1d186dad1ea673ae9a199a.zip | |
Merge pull request #369 from matthiasbeyer/clap-generate-shellcompletion
Add subcommand to generate completions, remove build.rs
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 14 |
2 files changed, 17 insertions, 0 deletions
@@ -51,4 +51,7 @@ pub enum ConfigCli { /// Disables loading of configuration file at default location clean: bool, }, + + #[structopt(name = "generate-completion")] + GenerateCompletion { shell: String }, } diff --git a/src/main.rs b/src/main.rs index ec249e8a..8da85c87 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); |
