Skip to content

Commit e65e463

Browse files
committedAug 9, 2024·
docs(complete): Have dynamic Shell match static Shell
1 parent 7fa2658 commit e65e463

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed
 

‎clap_complete/src/dynamic/shells/shell.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ use clap::ValueEnum;
1010
pub enum Shell {
1111
/// Bourne Again `SHell` (bash)
1212
Bash,
13+
/// Elvish shell
14+
Elvish,
1315
/// Friendly Interactive `SHell` (fish)
1416
Fish,
15-
/// Z shell (zsh)
16-
Zsh,
17-
/// Elf `SHell` (elvish)
18-
Elvish,
19-
/// Powerful `SHell` (powershel)
17+
/// `PowerShell`
2018
Powershell,
19+
/// Z `SHell` (zsh)
20+
Zsh,
2121
}
2222

2323
impl Shell {
@@ -75,10 +75,10 @@ fn parse_shell_from_path(path: &std::path::Path) -> Option<Shell> {
7575
let name = path.file_stem()?.to_str()?;
7676
match name {
7777
"bash" => Some(Shell::Bash),
78-
"zsh" => Some(Shell::Zsh),
79-
"fish" => Some(Shell::Fish),
8078
"elvish" => Some(Shell::Elvish),
79+
"fish" => Some(Shell::Fish),
8180
"powershell" | "powershell_ise" => Some(Shell::Powershell),
81+
"zsh" => Some(Shell::Zsh),
8282
_ => None,
8383
}
8484
}
@@ -110,20 +110,20 @@ impl ValueEnum for Shell {
110110
fn value_variants<'a>() -> &'a [Self] {
111111
&[
112112
Shell::Bash,
113-
Shell::Fish,
114-
Shell::Zsh,
115113
Shell::Elvish,
114+
Shell::Fish,
116115
Shell::Powershell,
116+
Shell::Zsh,
117117
]
118118
}
119119

120120
fn to_possible_value(&self) -> Option<PossibleValue> {
121121
Some(match self {
122122
Shell::Bash => PossibleValue::new("bash"),
123-
Shell::Fish => PossibleValue::new("fish"),
124-
Shell::Zsh => PossibleValue::new("zsh"),
125123
Shell::Elvish => PossibleValue::new("elvish"),
124+
Shell::Fish => PossibleValue::new("fish"),
126125
Shell::Powershell => PossibleValue::new("powershell"),
126+
Shell::Zsh => PossibleValue::new("zsh"),
127127
})
128128
}
129129
}
@@ -132,10 +132,10 @@ impl Shell {
132132
fn completer(&self) -> &dyn crate::dynamic::shells::ShellCompleter {
133133
match self {
134134
Self::Bash => &super::Bash,
135-
Self::Fish => &super::Fish,
136-
Self::Zsh => &super::Zsh,
137135
Self::Elvish => &super::Elvish,
136+
Self::Fish => &super::Fish,
138137
Self::Powershell => &super::Powershell,
138+
Self::Zsh => &super::Zsh,
139139
}
140140
}
141141
}

‎clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ _exhaustive() {
245245
fi
246246
case "${prev}" in
247247
--shell)
248-
COMPREPLY=($(compgen -W "bash fish zsh elvish powershell" -- "${cur}"))
248+
COMPREPLY=($(compgen -W "bash elvish fish powershell zsh" -- "${cur}"))
249249
return 0
250250
;;
251251
--register)

‎clap_complete/tests/snapshots/home/static/exhaustive/fish/fish/completions/exhaustive.fish

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ complete -c exhaustive -n "__fish_exhaustive_using_subcommand hint" -l email -r
136136
complete -c exhaustive -n "__fish_exhaustive_using_subcommand hint" -l global -d 'everywhere'
137137
complete -c exhaustive -n "__fish_exhaustive_using_subcommand hint" -s h -l help -d 'Print help'
138138
complete -c exhaustive -n "__fish_exhaustive_using_subcommand hint" -s V -l version -d 'Print version'
139-
complete -c exhaustive -n "__fish_exhaustive_using_subcommand complete" -l shell -d 'Specify shell to complete for' -r -f -a "{bash\t'',fish\t'',zsh\t'',elvish\t'',powershell\t''}"
139+
complete -c exhaustive -n "__fish_exhaustive_using_subcommand complete" -l shell -d 'Specify shell to complete for' -r -f -a "{bash\t'',elvish\t'',fish\t'',powershell\t'',zsh\t''}"
140140
complete -c exhaustive -n "__fish_exhaustive_using_subcommand complete" -l register -d 'Path to write completion-registration to' -r -F
141141
complete -c exhaustive -n "__fish_exhaustive_using_subcommand complete" -l global -d 'everywhere'
142142
complete -c exhaustive -n "__fish_exhaustive_using_subcommand complete" -s h -l help -d 'Print help (see more with \'--help\')'

‎clap_complete/tests/snapshots/home/static/exhaustive/zsh/zsh/_exhaustive

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ _arguments "${_arguments_options[@]}" : \
325325
;;
326326
(complete)
327327
_arguments "${_arguments_options[@]}" : \
328-
'--shell=[Specify shell to complete for]:SHELL:(bash fish zsh elvish powershell)' \
328+
'--shell=[Specify shell to complete for]:SHELL:(bash elvish fish powershell zsh)' \
329329
'--register=[Path to write completion-registration to]:REGISTER:_files' \
330330
'--global[everywhere]' \
331331
'-h[Print help (see more with '\''--help'\'')]' \

0 commit comments

Comments
 (0)
Please sign in to comment.