1use clap_complete::{Shell as ClapCompleteShell, aot::Generator};
2use clap_complete_nushell::Nushell;
3
4#[derive(Clone, Copy)]
5pub enum Shell {
6 ClapCompleteShell(ClapCompleteShell),
7 Nushell,
8}
9
10impl clap::ValueEnum for Shell {
11 fn value_variants<'a>() -> &'a [Self] {
12 &[
13 Self::ClapCompleteShell(ClapCompleteShell::Bash),
14 Self::ClapCompleteShell(ClapCompleteShell::Zsh),
15 Self::ClapCompleteShell(ClapCompleteShell::Fish),
16 Self::ClapCompleteShell(ClapCompleteShell::PowerShell),
17 Self::ClapCompleteShell(ClapCompleteShell::Elvish),
18 Self::Nushell,
19 ]
20 }
21
22 fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
23 match self {
24 Self::ClapCompleteShell(shell) => shell.to_possible_value(),
25 Self::Nushell => Some(clap::builder::PossibleValue::new("nushell")),
26 }
27 }
28}
29
30impl Generator for Shell {
31 fn file_name(&self, name: &str) -> String {
32 match self {
33 Self::ClapCompleteShell(shell) => shell.file_name(name),
34 Self::Nushell => Nushell.file_name(name),
35 }
36 }
37
38 fn generate(&self, cmd: &clap::Command, buf: &mut dyn std::io::Write) {
39 match self {
40 Self::ClapCompleteShell(shell) => shell.generate(cmd, buf),
41 Self::Nushell => Nushell.generate(cmd, buf),
42 }
43 }
44}