intermodal/src/shell.rs
Casey Rodarmor 8c30205b02
Add shell completion scripts
Shell completion scripts can be generated for `bash`, `elvish`, `fish`,
`powershell`, and `zsh` with the `completions` subcommand:

    $ imdl completions --shell zsh > imdl.zsh

The same scripts are available in the `completions` directory. Please
refer to your shell's documentation for more information on how to
install and use completion scripts.

type: added
2020-04-07 19:01:37 -07:00

36 lines
630 B
Rust

use super::*;
use structopt::clap;
#[derive(EnumVariantNames, EnumString)]
#[strum(serialize_all = "kebab-case")]
pub(crate) enum Shell {
Zsh,
Bash,
Fish,
Powershell,
Elvish,
}
impl Into<clap::Shell> for Shell {
fn into(self) -> clap::Shell {
match self {
Self::Bash => clap::Shell::Bash,
Self::Fish => clap::Shell::Fish,
Self::Zsh => clap::Shell::Zsh,
Self::Powershell => clap::Shell::PowerShell,
Self::Elvish => clap::Shell::Elvish,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn variants() {
assert_eq!(Shell::VARIANTS, clap::Shell::variants())
}
}