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
{{ message }}
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
I am trying re-implement HTTPie cli using clap-rs/structopt. I would like to have something like this
yahc.exe [METHOD] <URL> [REQUEST_ITEM]...
where METHOD is an optional positional arg enum with a default value
Describe the solution you'd like
It would be good if clap-rs allowed multiple optional positional arguments that get filled with a default value whenever the corresponding value fails to parse. For example, if we had:
test.exe [arg1] [arg2] [arg3]...
where:
arg1 has a type of enum Arg1 { Foo, Bar } and defaults to Arg1::Bar
Issue by ducaale
Tuesday Sep 01, 2020 at 18:51 GMT
Originally opened as clap-rs/clap#2122
Describe your use case
I am trying re-implement HTTPie cli using clap-rs/structopt. I would like to have something like this
where
METHOD
is an optional positional arg enum with a default valueDescribe the solution you'd like
It would be good if clap-rs allowed multiple optional positional arguments that get filled with a default value whenever the corresponding value fails to parse. For example, if we had:
where:
arg1
has a type ofenum Arg1 { Foo, Bar }
and defaults toArg1::Bar
arg2
has a type ofu32
and defaults to 0arg3
has a type ofVec<String>
a user can use the CLI app in the following ways:
test.exe
:arg1
=default_value
,arg2
=default_value
,arg3
=default_value
test.exe foo
:arg1
=foo
,arg2
=default_value
,arg3
=default_value
test.exe 1
:arg1
=default_value
,arg2
=1
,arg3
=default_value
test.exe hello
:arg1
=default_value
,arg2
=default_value
,arg3
=[hello]
test.exe foo hello
:arg1
=foo
,arg2
=default_value
,arg3
=[hello]
Alternatives, if applicable
I tried using the following but they didn't fit my use case:
AllowMissingPositional
can only be used when the last positional argument is requiredAdditional context
clap-rs/clap#2120
The text was updated successfully, but these errors were encountered: