Enum clap_complete::aot::Shell
source · #[non_exhaustive]pub enum Shell {
Bash,
Elvish,
Fish,
PowerShell,
Zsh,
}
Expand description
Shell with auto-generated completion script available.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Bash
Bourne Again SHell
(bash)
Elvish
Elvish shell
Fish
Friendly Interactive SHell
(fish)
PowerShell
PowerShell
Zsh
Z SHell
(zsh)
Implementations§
source§impl Shell
impl Shell
sourcepub fn from_shell_path<P: AsRef<Path>>(path: P) -> Option<Shell>
pub fn from_shell_path<P: AsRef<Path>>(path: P) -> Option<Shell>
Parse a shell from a path to the executable for the shell
§Examples
use clap_complete::shells::Shell;
assert_eq!(Shell::from_shell_path("/bin/bash"), Some(Shell::Bash));
assert_eq!(Shell::from_shell_path("/usr/bin/zsh"), Some(Shell::Zsh));
assert_eq!(Shell::from_shell_path("/opt/my_custom_shell"), None);
sourcepub fn from_env() -> Option<Shell>
pub fn from_env() -> Option<Shell>
Determine the user’s current shell from the environment
This will read the SHELL environment variable and try to determine which shell is in use from that.
If SHELL is not set, then on windows, it will default to powershell, and on
other operating systems it will return None
.
If SHELL is set, but contains a value that doesn’t correspond to one of the supported shell
types, then return None
.
§Example:
use clap_complete::{generate, shells::Shell};
let mut cmd = build_cli();
generate(Shell::from_env().unwrap_or(Shell::Bash), &mut cmd, "myapp", &mut std::io::stdout());
Trait Implementations§
impl Copy for Shell
impl Eq for Shell
impl StructuralPartialEq for Shell
Auto Trait Implementations§
impl Freeze for Shell
impl RefUnwindSafe for Shell
impl Send for Shell
impl Sync for Shell
impl Unpin for Shell
impl UnwindSafe for Shell
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)