]>
git.proxmox.com Git - rustc.git/blob - vendor/clap/src/completions/shell.rs
1 #[allow(deprecated, unused_imports)]
2 use std
::ascii
::AsciiExt
;
6 /// Describes which shell to produce a completions file for
7 #[derive(Debug, Copy, Clone)]
9 /// Generates a .bash completion file for the Bourne Again SHell (BASH)
11 /// Generates a .fish completion file for the Friendly Interactive SHell (fish)
13 /// Generates a completion file for the Z SHell (ZSH)
15 /// Generates a completion file for PowerShell
17 /// Generates a completion file for Elvish
22 /// A list of possible variants in `&'static str` form
23 pub fn variants() -> [&'
static str; 5] {
24 ["zsh", "bash", "fish", "powershell", "elvish"]
28 impl FromStr
for Shell
{
31 #[cfg_attr(feature = "cargo-clippy", allow(clippy::wildcard_in_or_patterns))]
32 fn from_str(s
: &str) -> Result
<Self, Self::Err
> {
34 "ZSH" | _
if s
.eq_ignore_ascii_case("zsh") => Ok(Shell
::Zsh
),
35 "FISH" | _
if s
.eq_ignore_ascii_case("fish") => Ok(Shell
::Fish
),
36 "BASH" | _
if s
.eq_ignore_ascii_case("bash") => Ok(Shell
::Bash
),
37 "POWERSHELL" | _
if s
.eq_ignore_ascii_case("powershell") => Ok(Shell
::PowerShell
),
38 "ELVISH" | _
if s
.eq_ignore_ascii_case("elvish") => Ok(Shell
::Elvish
),
39 _
=> Err(String
::from(
40 "[valid values: bash, fish, zsh, powershell, elvish]",
46 impl fmt
::Display
for Shell
{
47 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
49 Shell
::Bash
=> write
!(f
, "BASH"),
50 Shell
::Fish
=> write
!(f
, "FISH"),
51 Shell
::Zsh
=> write
!(f
, "ZSH"),
52 Shell
::PowerShell
=> write
!(f
, "POWERSHELL"),
53 Shell
::Elvish
=> write
!(f
, "ELVISH"),