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/main.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/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 0eeb57bf..73d60bb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,10 @@ use std::process::Command; use std::{env, mem}; use clap::{CommandFactory, Parser}; +use clap_complete::Shell; +use clap_complete_nushell::Nushell; use directories::ProjectDirs; -use niri::cli::{Cli, Sub}; +use niri::cli::{Cli, CompletionShell, Sub}; #[cfg(feature = "dbus")] use niri::dbus; use niri::ipc::client::handle_msg; @@ -108,7 +110,25 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { } Sub::Panic => cause_panic(), Sub::Completions { shell } => { - clap_complete::generate(shell, &mut Cli::command(), "niri", &mut io::stdout()); + match shell { + CompletionShell::Nushell => { + clap_complete::generate( + Nushell, + &mut Cli::command(), + "niri", + &mut io::stdout(), + ); + } + other => { + let generator = Shell::try_from(other).unwrap(); + clap_complete::generate( + generator, + &mut Cli::command(), + "niri", + &mut io::stdout(), + ); + } + } return Ok(()); } } |
