mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
feat(parsr): Expose all built-in TypedValueParsers
This makes life easier for people, whether they want a geneirc `NonEmpty<impl TypedValueParser>` or a `PathBufExists(PathBuf)`.
This commit is contained in:
parent
2ffa38f9f5
commit
6b0306df9e
2 changed files with 20 additions and 4 deletions
|
@ -34,10 +34,14 @@ pub use value_parser::via_prelude;
|
|||
pub use value_parser::AnyValueParser;
|
||||
pub use value_parser::ArgEnumValueParser;
|
||||
pub use value_parser::AutoValueParser;
|
||||
pub use value_parser::BoolValueParser;
|
||||
pub use value_parser::BoolishValueParser;
|
||||
pub use value_parser::FalseyValueParser;
|
||||
pub use value_parser::NonEmptyStringValueParser;
|
||||
pub use value_parser::OsStringValueParser;
|
||||
pub use value_parser::PathBufValueParser;
|
||||
pub use value_parser::PossibleValuesParser;
|
||||
pub use value_parser::StringValueParser;
|
||||
pub use value_parser::TypedValueParser;
|
||||
pub use value_parser::ValueParser;
|
||||
|
||||
|
|
|
@ -404,8 +404,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation for [`ValueParser::string`]
|
||||
///
|
||||
/// Useful for composing new [`TypedValueParser`]s
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct StringValueParser;
|
||||
pub struct StringValueParser;
|
||||
|
||||
impl TypedValueParser for StringValueParser {
|
||||
type Value = String;
|
||||
|
@ -435,8 +438,11 @@ impl TypedValueParser for StringValueParser {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation for [`ValueParser::os_string`]
|
||||
///
|
||||
/// Useful for composing new [`TypedValueParser`]s
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct OsStringValueParser;
|
||||
pub struct OsStringValueParser;
|
||||
|
||||
impl TypedValueParser for OsStringValueParser {
|
||||
type Value = std::ffi::OsString;
|
||||
|
@ -460,8 +466,11 @@ impl TypedValueParser for OsStringValueParser {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation for [`ValueParser::path_buf`]
|
||||
///
|
||||
/// Useful for composing new [`TypedValueParser`]s
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct PathBufValueParser;
|
||||
pub struct PathBufValueParser;
|
||||
|
||||
impl TypedValueParser for PathBufValueParser {
|
||||
type Value = std::path::PathBuf;
|
||||
|
@ -730,8 +739,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation for [`ValueParser::bool`]
|
||||
///
|
||||
/// Useful for composing new [`TypedValueParser`]s
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct BoolValueParser;
|
||||
pub struct BoolValueParser;
|
||||
|
||||
impl BoolValueParser {
|
||||
fn possible_values() -> impl Iterator<Item = crate::PossibleValue<'static>> {
|
||||
|
|
Loading…
Reference in a new issue