Skip to content

Commit 3cb5520

Browse files
authored
feat(boil): Add support for Nushell completions (#1259)
1 parent e1cb0e1 commit 3cb5520

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "Apache-2.0"
1010
[workspace.dependencies]
1111
clap = { version = "4.5.41", features = ["derive"] }
1212
clap_complete = "4.5.55"
13+
clap_complete_nushell = "4.5.8"
1314
git2 = "0.20.1"
1415
glob = "0.3.2"
1516
oci-spec = "0.8.2"

rust/boil/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ publish = false
1010
[dependencies]
1111
clap.workspace = true
1212
clap_complete.workspace = true
13+
clap_complete_nushell.workspace = true
1314
git2.workspace = true
1415
glob.workspace = true
1516
oci-spec.workspace = true

rust/boil/src/completions/mod.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
use clap::{Args, CommandFactory};
2-
use clap_complete::Shell;
1+
use clap::{Args, Command, CommandFactory, ValueEnum};
2+
use clap_complete::{
3+
Generator,
4+
Shell::{Bash, Elvish, Fish, Zsh},
5+
};
6+
use clap_complete_nushell::Nushell;
37

48
use crate::cli::Cli;
59

610
#[derive(Debug, Args)]
711
pub struct CompletionsArguments {
812
/// Shell to generate completions for.
13+
#[arg(value_enum)]
914
pub shell: Shell,
1015
}
1116

17+
#[derive(Clone, Debug, ValueEnum)]
18+
pub enum Shell {
19+
/// Bourne Again SHell
20+
Bash,
21+
22+
/// Elvish shell
23+
Elvish,
24+
25+
/// Friendly Interactive SHell
26+
Fish,
27+
28+
/// Z SHell
29+
Zsh,
30+
31+
/// Nushell
32+
Nushell,
33+
}
34+
1235
/// This is the `boil completions` command handler function.
1336
pub fn run_command(arguments: CompletionsArguments) {
1437
let mut cli = Cli::command();
1538
let bin_name = cli.get_bin_name().unwrap_or("boil").to_owned();
1639

17-
clap_complete::generate(arguments.shell, &mut cli, bin_name, &mut std::io::stdout());
40+
match arguments.shell {
41+
Shell::Bash => generate(Bash, &mut cli, bin_name),
42+
Shell::Elvish => generate(Elvish, &mut cli, bin_name),
43+
Shell::Fish => generate(Fish, &mut cli, bin_name),
44+
Shell::Zsh => generate(Zsh, &mut cli, bin_name),
45+
Shell::Nushell => generate(Nushell, &mut cli, bin_name),
46+
}
47+
}
48+
49+
fn generate(generator: impl Generator, cli: &mut Command, bin_name: String) {
50+
clap_complete::generate(generator, cli, bin_name, &mut std::io::stdout());
1851
}

0 commit comments

Comments
 (0)