structopt_utilities/completions/
shell.rs1use core::hint::unreachable_unchecked;
2use structopt::clap::{self, Shell::*};
3
4#[derive(Debug, Copy, Clone)]
6pub struct Shell(pub clap::Shell);
7
8impl Shell {
9 pub unsafe fn parse_from_str_unchecked(text: &str) -> Self {
16 Shell(match text {
17 "bash" => Bash,
18 "fish" => Fish,
19 "zsh" => Zsh,
20 "powershell" => PowerShell,
21 "elvish" => Elvish,
22 _ => unreachable_unchecked(),
23 })
24 }
25
26 pub fn to_clap(self) -> clap::Shell {
28 self.0
29 }
30
31 pub fn from_clap(clap: clap::Shell) -> Self {
33 Shell(clap)
34 }
35}
36
37impl PartialEq for Shell {
38 fn eq(&self, other: &Self) -> bool {
39 matches!(
40 (self.0, other.0),
41 (Bash, Bash) | (Fish, Fish) | (Zsh, Zsh) | (PowerShell, PowerShell) | (Elvish, Elvish)
42 )
43 }
44}
45
46impl Eq for Shell {}