diff options
| author | Artrix <sefu786@outlook.com> | 2025-07-13 23:29:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-14 06:29:26 +0000 |
| commit | 746a7e81b79f8b663e0ab393ab2f192340da38e2 (patch) | |
| tree | 8d9c8ff44dd4ea084ccfc51172a104931ba445a6 /src/cli.rs | |
| parent | 51b6a495c5ab701bb3ef4d1180e4fe190acc4f60 (diff) | |
| download | niri-746a7e81b79f8b663e0ab393ab2f192340da38e2.tar.gz niri-746a7e81b79f8b663e0ab393ab2f192340da38e2.tar.bz2 niri-746a7e81b79f8b663e0ab393ab2f192340da38e2.zip | |
Add nushell completion support (#2009)
* Add nushell completion support
Adds `clap_complete_nushell` crate and implements it into the `niri
completions` command.
* Add nushell to flake.nix autocompletions
* Convert to `TryFrom`
* Fix linting errors
* Move types down
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -56,7 +56,7 @@ pub enum Sub { /// Cause a panic to check if the backtraces are good. Panic, /// Generate shell completions. - Completions { shell: Shell }, + Completions { shell: CompletionShell }, } #[derive(Subcommand)] @@ -108,3 +108,28 @@ pub enum Msg { /// Print the overview state. OverviewState, } + +#[derive(Clone, Debug, clap::ValueEnum)] +pub enum CompletionShell { + Bash, + Elvish, + Fish, + PowerShell, + Zsh, + Nushell, +} + +impl TryFrom<CompletionShell> for Shell { + type Error = &'static str; + + fn try_from(shell: CompletionShell) -> Result<Self, Self::Error> { + match shell { + CompletionShell::Bash => Ok(Shell::Bash), + CompletionShell::Elvish => Ok(Shell::Elvish), + CompletionShell::Fish => Ok(Shell::Fish), + CompletionShell::PowerShell => Ok(Shell::PowerShell), + CompletionShell::Zsh => Ok(Shell::Zsh), + CompletionShell::Nushell => Err("Nushell should be handled separately"), + } + } +} |
