Replies: 1 comment 3 replies
-
@pksunkara is the thumbs up a go-ahead to turn this into an issue and implement? I lean towards always-valid |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Arg::new()
creates a positional argument thattakes_value(true)
Args::new().long()
creates a named flag (takes_value(false)
)Args::new().long().takes_value(true)
is required to created a named arg / optionThis requires us to guess the users intent at various stages. kbknapp explained this when trying to explain existing challenges with
values
vsoccurrences
:I'm even running into a problem I'm debugging for #751 that I think comes from this.
Just a small tweak would make clap less brittle for change and I believe make the user experience better, if we switch to
Arg::new()
creates a positional argument thattakes_value(true)
Args::new().long()
creates a named arg / option (ietakes_value(true)
)Args::new().long().takes_value(false)
is required to created a flag@kbknapp was open to changing this, though with a different approach (this was before clarifying the approach above, see below for his thoughts on each approach)
We could fix the "always valid object" problem by instead making some helper constructors (
positional
,flag
, andoption
where the latter take long names since 99% of the time, they are used)Between flag-opt-in and construct invalid options (I didn't bring up the named constructors), kbknapp said
Beta Was this translation helpful? Give feedback.
All reactions