Skip to content

Commit 4206699

Browse files
committed
fix(builder): Quote empty default values
1 parent eb16ae4 commit 4206699

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clap_builder/src/util/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) struct Escape<'s>(pub(crate) &'s str);
55

66
impl<'s> Escape<'s> {
77
pub(crate) fn needs_escaping(&self) -> bool {
8-
self.0.contains(char::is_whitespace)
8+
self.0.is_empty() || self.0.contains(char::is_whitespace)
99
}
1010

1111
#[cfg(feature = "help")]

tests/builder/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ fn empty_default_value() {
20442044
Usage: default [OPTIONS]
20452045
20462046
Options:
2047-
--arg <argument> Pass an argument to the program. [default: ]
2047+
--arg <argument> Pass an argument to the program. [default: ""]
20482048
-h, --help Print help
20492049
-V, --version Print version
20502050

0 commit comments

Comments
 (0)