You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A-helpArea: documentation, including docs.rs, readme, examples, etc...C-bugCategory: Updating dependenciesE-easyCall for participation: Experience needed to fix: Easy / not much
In this proposed feature enhancement, all Display values would be disambiguated via single quote ', so some examples:
field type String displays [default '']
field type i64 displays [default '0']
field type bool displays [default 'false']
Additional Context
The display of default_value_t defaults just literally uses Display, which can be confusing for a variety of defaults:
empty string (like in this example)
strings containing ']' or other symbols.
unlikely / pathological cases:
newlines
In my "expected behavior" I'm imagining consistent shell-like escaping. This need not be literal shell syntax (especially because users can vary which shells they use and across platforms), but only "unambiguous to typical commandline users".
Simply surrounding the Display value with single ticks ' handles the empty string case, but introduces an escaping problem with Display values that contain '. So this complication would make this feature improvement a bit more messy.
I filed this as a bug, because I consider UX issues which may cause confusion to users as bugs. I could also see categorizing this as a feature/enhancement.
epage
added
A-help
Area: documentation, including docs.rs, readme, examples, etc...
E-easy
Call for participation: Experience needed to fix: Easy / not much
labels
Jun 19, 2023
Is it ideal to quote for String that is empty or contain spaces?
As a solution, I suggest creating a function to wrap a string by '' or "" and use it in help_template.rs and possible_value.rs.
In that case, I believe there would be no need to change format.rs, as it will always enclose a string by '', regardless of whitespace or empty strings.
A-helpArea: documentation, including docs.rs, readme, examples, etc...C-bugCategory: Updating dependenciesE-easyCall for participation: Experience needed to fix: Easy / not much
Please complete the following tasks
Rust Version
rustc 1.69.0 (84c898d65 2023-04-16)
Clap Version
4.3.4
Minimal reproducible code
Steps to reproduce the bug with the above code
Actual Behaviour
Expected Behaviour
I do not think this "should" happen given the current release, but IMO it would be more ideal:
In this proposed feature enhancement, all
Display
values would be disambiguated via single quote'
, so some examples:String
displays[default '']
i64
displays[default '0']
bool
displays[default 'false']
Additional Context
The display of
default_value_t
defaults just literally usesDisplay
, which can be confusing for a variety of defaults:unlikely / pathological cases:
In my "expected behavior" I'm imagining consistent shell-like escaping. This need not be literal shell syntax (especially because users can vary which shells they use and across platforms), but only "unambiguous to typical commandline users".
Simply surrounding the
Display
value with single ticks'
handles the empty string case, but introduces an escaping problem withDisplay
values that contain'
. So this complication would make this feature improvement a bit more messy.Perhaps
\'
-style escapes would be simple enough?-would produce:
Debug Output
n/a
The text was updated successfully, but these errors were encountered: