diff options
| author | Matthias Beyer <mail@beyermatthias.de> | 2021-04-25 14:33:53 +0200 |
|---|---|---|
| committer | Matthias Beyer <mail@beyermatthias.de> | 2021-04-25 14:33:53 +0200 |
| commit | 9aca589167fec7b5b309c60208bd4cd203bc9c6e (patch) | |
| tree | 8fc6394398b9064194b860580952097bd5bfb8ba /src | |
| parent | Merge pull request #356 from zellij-org/add-auto-release (diff) | |
| download | sl0ppij-9aca589167fec7b5b309c60208bd4cd203bc9c6e.tar.gz sl0ppij-9aca589167fec7b5b309c60208bd4cd203bc9c6e.tar.xz sl0ppij-9aca589167fec7b5b309c60208bd4cd203bc9c6e.zip | |
Add subcommand to generate completions
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 14 |
2 files changed, 20 insertions, 0 deletions
@@ -51,4 +51,10 @@ 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..377ef4f6 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(); |
