mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
fix(parser): Disallow empty paths
This commit is contained in:
parent
ec186487b6
commit
2e57f1fca7
1 changed files with 11 additions and 2 deletions
|
@ -342,10 +342,19 @@ impl TypedValueParser for PathBufValueParser {
|
|||
|
||||
fn parse(
|
||||
&self,
|
||||
_cmd: &crate::Command,
|
||||
_arg: Option<&crate::Arg>,
|
||||
cmd: &crate::Command,
|
||||
arg: Option<&crate::Arg>,
|
||||
value: std::ffi::OsString,
|
||||
) -> Result<Self::Value, crate::Error> {
|
||||
if value.is_empty() {
|
||||
return Err(crate::Error::empty_value(
|
||||
cmd,
|
||||
&[],
|
||||
arg.map(ToString::to_string)
|
||||
.unwrap_or_else(|| "...".to_owned()),
|
||||
crate::output::Usage::new(cmd).create_usage_with_title(&[]),
|
||||
));
|
||||
}
|
||||
Ok(Self::Value::from(value))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue