-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
A-deriveArea: #[derive]` macro APIArea: #[derive]` macro APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectations
Milestone
Description
This is actually a summary of TeXitoi/structopt#364
Current behavior
Vec<T>
andOption<Vec<T>>
are notrequired = true
by default.Vec<T>
ismultiple = true
by default which allows not only multiple values (--foo 1 2 3
) but also multiple occurrences (--foo 1 --foo 2 3
).Option<Vec<T>>
additionally allows zero number of values (--foo
).
What's wrong
- The fact that
Vec<T>
is notrequired
by default is inconsistent with all the other types inclap_derive
that are required by default unless they are wrapped inOption
(exceptbool
but it's a very special case). - The fact that
Option<Vec<T>>
is different fromVec<T>
, different not in "not required" sense, confuses newcomers. - The fact that
Vec<T>
allows multiple occurrences along with values is misleading.
Proposal
- Use
min_values = 1
for bothOption<Vec<T>>
andVec<T>
instead ofmultiple = true
, allowing only non-zero number of values and disallow multiple occurrences (--foo 1 2
but not--foo
nor--foo 1 --foo 2
). If a user wants to allow zero values or multiple occurrences as well, they can explicitly specify it viamin_values = 0
andmultiple = true
respectively. - Use
required = true
forVec<T>
.
schneiderfelipe
Metadata
Metadata
Assignees
Labels
A-deriveArea: #[derive]` macro APIArea: #[derive]` macro APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectations