Enum ValueHint
#[non_exhaustive]
pub enum ValueHint
Provide shell with hint on how to complete an argument.
See [Arg::value_hint][crate::Arg::value_hint] to set this on an argument.
See the clap_complete crate for completion script generation.
Overview of which hints are supported by which shell:
| Hint | zsh | fish1 | dynamic |
|---|---|---|---|
AnyPath |
Yes | Yes | Yes |
FilePath |
Yes | Yes | Yes |
DirPath |
Yes | Yes | Yes |
ExecutablePath |
Yes | Partial | Yes |
CommandName |
Yes | Yes | No |
CommandString |
Yes | Partial | No |
CommandWithArguments |
Yes | No | |
Username |
Yes | Yes | No |
Hostname |
Yes | Yes | No |
Url |
Yes | No | |
EmailAddress |
Yes | No |
-
fish completions currently only support named arguments (e.g. -o or --opt), not positional arguments. ↩
Variants
-
Unknown Default value if hint is not specified. Follows shell default behavior, which is usually auto-completing filenames.
-
Other None of the hints below apply. Disables shell completion for this argument.
-
AnyPath Any existing path.
-
FilePath Path to a file.
-
DirPath Path to a directory.
-
ExecutablePath Path to an executable file.
-
CommandName Name of a command, without arguments. May be relative to PATH, or full path to executable.
-
CommandString A single string containing a command and its arguments.
-
CommandWithArguments Capture the remaining arguments as a command name and arguments for that command. This is common when writing shell wrappers that execute another command, for example
sudoorenv.This hint is special, the argument must be a positional argument and have
.num_args(1..)and Command must useCommand::trailing_var_arg(true). The result is that the command linemy_app ls -la /will be parsed as["ls", "-la", "/"]and clap won't try to parse the-laargument itself.-
Username Name of a local operating system user.
-
Hostname Host name of a computer. Shells usually parse
/etc/hostsand.ssh/known_hoststo complete hostnames.-
Url Complete web address.
-
EmailAddress Email address.
Trait Implementations
impl Clone for ValueHint
fn clone(&self) -> ValueHint
impl Copy for ValueHint
impl Debug for ValueHint
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for ValueHint
fn default() -> ValueHint
impl Eq for ValueHint
impl FromStr for ValueHint
type Err = String;fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err>
impl Hash for ValueHint
fn hash<__H: Hasher>(&self, state: &mut __H)
impl IntoResettable<ValueHint> for ValueHint
fn into_resettable(self) -> Resettable<ValueHint>
impl PartialEq for ValueHint
fn eq(&self, other: &ValueHint) -> bool
impl StructuralPartialEq for ValueHint
Auto Trait Implementations
impl Freeze for ValueHint
impl RefUnwindSafe for ValueHint
impl Send for ValueHint
impl Sync for ValueHint
impl Unpin for ValueHint
impl UnsafeUnpin for ValueHint
impl UnwindSafe for ValueHint
Blanket Implementations
impl<T> Any for ValueHint
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ValueHint
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ValueHint
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ValueHint
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ValueHint
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ValueHint
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for ValueHint
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ValueHint
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for ValueHint
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>