Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51947
| References | <51fdb81b$0$2423$426a74cc@news.free.fr> <51ff0881$0$2218$426a74cc@news.free.fr> |
|---|---|
| From | Joshua Landau <joshua@landau.ws> |
| Date | 2013-08-05 04:53 +0100 |
| Subject | Re: [argparse] mutually exclusive group with 2 sets of options |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.198.1375674871.1251.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 5 August 2013 03:05, Francois Lafont <francois.lafont@nospam.invalid>wrote:
> Hello,
>
> Up. ;-)
>
> Le 04/08/2013 04:10, Francois Lafont a écrit :
>
> > Is it possible with argparse to have this syntax for a script?
> >
> > my-script (-a -b VALUE-B | -c -d VALUE-D)
> >
> > I would like to do this with the argparse module.
> >
> > Thanks in advance.
>
> I have found this post:
>
> https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ
>
> It was in 2011 and at that time, it was impossible to have the syntax
> above. I have the impression that it's impossible now yet. Am I wrong?
>
> If it's impossible yet, I could try a hack. With some checks, I think I
> could have the "(-a -b VALUE-B | -c -d VALUE-D)" behavior but I would like
> this syntax appear in the help output too and I have no idea to do it.
If possible you could try docopt. That should be able to do it quite easily.
You could write literally:
My-Script
Usage:
my-script (-a -b VALUE-B | -c -d VALUE-D)
Options:
-b VALUE-B Description
-d VALUE-D Description
as the grammar, but:
My-Script
Usage:
my-script -a -b VALUE-B
my-script -c -d VALUE-D
Options:
-b VALUE-B Description
-d VALUE-D Description
would be preferred.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-04 04:10 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-05 04:05 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Joshua Landau <joshua@landau.ws> - 2013-08-05 04:53 +0100
Re: [argparse] mutually exclusive group with 2 sets of options Miki Tebeka <miki.tebeka@gmail.com> - 2013-08-05 07:11 -0700
RE: [argparse] mutually exclusive group with 2 sets of options "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-08-05 17:11 +0000
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-06 00:13 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2013-08-05 22:01 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-06 00:34 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-07 01:18 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-07 01:36 +0200
RE: [argparse] mutually exclusive group with 2 sets of options "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-08-05 22:15 +0000
csiph-web