Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ';-)': 0.03; 'subject:: [': 0.04; 'syntax': 0.04; 'yet.': 0.04; 'output': 0.05; 'preferred.': 0.05; 'subject:group': 0.05; 'script?': 0.16; 'subject:argparse': 0.16; 'subject:options': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'advance.': 0.19; 'subject:] ': 0.20; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'appear': 0.29; 'message-id:@mail.gmail.com': 0.30; 'quite': 0.32; 'up.': 0.33; 'to:name:python-list': 0.33; 'could': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'impression': 0.36; 'module.': 0.36; 'options:': 0.36; 'thanks': 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:\xc2 10': 0.60; 'august': 0.61; '8bit%:27': 0.74; 'behavior': 0.77; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=mBoHkqdUPJylNv0dcKNTh9A5UqKOzxoDj1C7Zdsvup8=; b=UBdyEB2Q7WOKYS7ou7DwolObBfw0UCYRzBSHgxzvrUZLgshuAuArmdKmyCWglS3jP9 okMTcZg6NgbAz3WSh/8Zk/N23ndcDdyOV6QunEtitwboOTqC6zhbyNBs147+tqfWgNFs CdDQ98Z3hGz4GHZu7rdiOmAWilgDQE9PzZu7BDKUC9y/8Xlu6bqgsaesbd4J1BbXvvuR DZuYErRlMMeYlqknNe1ScLK/wI0IXOe47MpXHXfH3HRxQw5Vla/ITEboITpxcenBWjV8 9lfLADLitYQ4MjqTYlWSStMnF+lCKDaOn0OGoFWYQRK6zO6nUYjzdulMZV+Wtw2UCRjr 7u1g== X-Received: by 10.152.45.65 with SMTP id k1mr7618898lam.78.1375674863497; Sun, 04 Aug 2013 20:54:23 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: <51ff0881$0$2218$426a74cc@news.free.fr> References: <51fdb81b$0$2423$426a74cc@news.free.fr> <51ff0881$0$2218$426a74cc@news.free.fr> From: Joshua Landau Date: Mon, 5 Aug 2013 04:53:43 +0100 X-Google-Sender-Auth: y4aj4nBLV3HfvKp25Zwh4ZFfdEM Subject: Re: [argparse] mutually exclusive group with 2 sets of options To: python-list Content-Type: multipart/alternative; boundary=001a11c1b7ae90b60c04e32b4353 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 124 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375674871 news.xs4all.nl 15942 [2001:888:2000:d::a6]:55051 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51947 --001a11c1b7ae90b60c04e32b4353 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 5 August 2013 03:05, Francois Lafont wro= te: > Hello, > > Up. ;-) > > Le 04/08/2013 04:10, Francois Lafont a =C3=A9crit : > > > 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/argpa= rse-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 lik= e > 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. --001a11c1b7ae90b60c04e32b4353 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 5 August 2013 03:05, Francois Lafont = <fra= ncois.lafont@nospam.invalid> wrote:
Hello,

Up. ;-)

Le 04/08/2013 04:10, Francois Lafont a =C3=A9crit :

> 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://grou= ps.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6G= OwhCjbQ/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 t= o do it quite easily.

You could write literally:

=C2=A0 =C2=A0 My-Script

= =C2=A0 =C2=A0 Usage:
=C2=A0 =C2=A0 =C2=A0 my-script (-a -b VALUE-B | -c -d VALUE-D)

=C2=A0 =C2=A0 Options:
=C2=A0 =C2=A0 =C2=A0 -b = VALUE-B =C2=A0Description
=C2=A0 =C2=A0 =C2=A0 -d VALUE-D =C2=A0D= escription=C2=A0

as the grammar, but:

=C2=A0 =C2=A0 My-Script
=C2=A0 =C2=A0=C2= =A0
=C2=A0 =C2=A0 Usage:
=C2=A0 =C2=A0 =C2=A0 my-script= -a -b VALUE-B
=C2=A0 =C2=A0 =C2=A0 my-script -c -d VALUE-D
=
=C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 Options:
=C2=A0 = =C2=A0 =C2=A0 -b VALUE-B =C2=A0Description
=C2=A0 =C2=A0 =C2=A0 -d VALUE-D =C2=A0Description

=
would be preferred.
--001a11c1b7ae90b60c04e32b4353--