pub struct PathType {
pub exists: bool,
pub file_okay: bool,
pub dir_okay: bool,
pub readable: bool,
pub writable: bool,
pub executable: bool,
pub resolve_path: bool,
pub allow_dash: bool,
}Expand description
A parameter type for file system paths with optional validation.
Unlike the File type, this returns the path as a PathBuf rather
than opening the file.
Fields§
§exists: boolWhether the path must exist.
file_okay: boolWhether files are allowed.
dir_okay: boolWhether directories are allowed.
readable: boolWhether the path must be readable.
writable: boolWhether the path must be writable.
executable: boolWhether the path must be executable.
resolve_path: boolWhether to resolve the path to an absolute path.
allow_dash: boolWhether to allow “-” to indicate stdin/stdout.
Implementations§
Source§impl PathType
impl PathType
Sourcepub const fn executable(self, executable: bool) -> Self
pub const fn executable(self, executable: bool) -> Self
Require the path to be executable.
Sourcepub const fn resolve_path(self, resolve_path: bool) -> Self
pub const fn resolve_path(self, resolve_path: bool) -> Self
Resolve the path to an absolute path.
Sourcepub const fn allow_dash(self, allow_dash: bool) -> Self
pub const fn allow_dash(self, allow_dash: bool) -> Self
Allow “-” to indicate stdin/stdout.
Trait Implementations§
Source§impl TypeConverter for PathType
impl TypeConverter for PathType
Source§fn convert(&self, value: &str) -> Result<Self::Value, String>
fn convert(&self, value: &str) -> Result<Self::Value, String>
Convert a string value to the target type. Read more
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values. Read more
Source§fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type (used in help text). Read more
Source§fn get_missing_message(&self) -> Option<String>
fn get_missing_message(&self) -> Option<String>
Returns an optional message when a required value is missing.
Source§fn is_composite(&self) -> bool
fn is_composite(&self) -> bool
Whether this type is a composite type (like Tuple).
Auto Trait Implementations§
impl Freeze for PathType
impl RefUnwindSafe for PathType
impl Send for PathType
impl Sync for PathType
impl Unpin for PathType
impl UnsafeUnpin for PathType
impl UnwindSafe for PathType
Blanket Implementations§
Source§impl<T> AnyTypeConverter for T
impl<T> AnyTypeConverter for T
Source§fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
Convert a string value to the target type, returning as Box.
Source§fn convert_multi(
&self,
values: &[String],
) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Sync + Send>, String>
Convert multiple string values to the target type, returning as Box. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type.
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values.
Source§fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value.
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