#[non_exhaustive]pub enum ParameterSource {
CommandLine,
Environment,
Default,
DefaultMap,
Prompt,
}Expand description
Indicates the source of a parameter’s value.
Use [Context::get_parameter_source] to get the source for a parameter by name.
§Precedence
Sources have a defined precedence order (highest to lowest):
CommandLine- Explicit user inputEnvironment- Environment variablesDefaultMap- Context default mapDefault- Parameter default value
Prompt is considered equal to CommandLine for precedence
since both represent direct user input.
§Example
use click::ParameterSource;
let source = ParameterSource::CommandLine;
assert!(source.is_from_user());
let env_source = ParameterSource::Environment;
assert!(!env_source.is_from_user());
// CommandLine has higher precedence than Environment
assert!(ParameterSource::CommandLine > ParameterSource::Environment);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.
CommandLine
The value was provided by command line arguments.
Environment
The value was provided via an environment variable.
Default
The value used the default specified by the parameter.
DefaultMap
The value used a default provided by the context’s default_map.
Prompt
The value was provided via an interactive prompt.
Implementations§
Source§impl ParameterSource
impl ParameterSource
Sourcepub fn is_from_user(&self) -> bool
pub fn is_from_user(&self) -> bool
Returns true if the value came from direct user input.
This returns true for CommandLine
and Prompt, as both represent values
explicitly provided by the user during execution.
§Example
use click::ParameterSource;
assert!(ParameterSource::CommandLine.is_from_user());
assert!(ParameterSource::Prompt.is_from_user());
assert!(!ParameterSource::Environment.is_from_user());
assert!(!ParameterSource::Default.is_from_user());
assert!(!ParameterSource::DefaultMap.is_from_user());Trait Implementations§
Source§impl Clone for ParameterSource
impl Clone for ParameterSource
Source§fn clone(&self) -> ParameterSource
fn clone(&self) -> ParameterSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ParameterSource
Source§impl Debug for ParameterSource
impl Debug for ParameterSource
Source§impl Display for ParameterSource
impl Display for ParameterSource
impl Eq for ParameterSource
Source§impl Hash for ParameterSource
impl Hash for ParameterSource
Source§impl Ord for ParameterSource
impl Ord for ParameterSource
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ParameterSource
impl PartialEq for ParameterSource
Source§fn eq(&self, other: &ParameterSource) -> bool
fn eq(&self, other: &ParameterSource) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ParameterSource
impl PartialOrd for ParameterSource
impl StructuralPartialEq for ParameterSource
Auto Trait Implementations§
impl Freeze for ParameterSource
impl RefUnwindSafe for ParameterSource
impl Send for ParameterSource
impl Sync for ParameterSource
impl Unpin for ParameterSource
impl UnsafeUnpin for ParameterSource
impl UnwindSafe for ParameterSource
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