<div dir="ltr">On 5 August 2013 03:05, Francois Lafont <span dir="ltr"><<a href="mailto:francois.lafont@nospam.invalid" target="_blank">francois.lafont@nospam.invalid</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
<br>
Up. ;-)<br>
<br>
Le 04/08/2013 04:10, Francois Lafont a écrit :<br>
<div class="im"><br>
> Is it possible with argparse to have this syntax for a script?<br>
><br>
> my-script (-a -b VALUE-B | -c -d VALUE-D)<br>
><br>
> I would like to do this with the argparse module.<br>
><br>
> Thanks in advance.<br>
<br>
</div>I have found this post:<br>
<a href="https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ" target="_blank">https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ</a><br>


<br>
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?<br>
<br>
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.</blockquote>

<div><br></div><div>If possible you could try docopt. That should be able to do it quite easily.</div><div><br></div><div>You could write literally:</div><div><br></div><div>    My-Script</div><div><br></div><div>    Usage:</div>

<div>      my-script (-a -b VALUE-B | -c -d VALUE-D)</div><div><br></div><div>    Options:</div><div>      -b VALUE-B  Description</div><div>      -d VALUE-D  Description </div><div><br></div><div>as the grammar, but:</div>

<div><br></div><div><div>    My-Script</div><div>    </div><div>    Usage:</div><div>      my-script -a -b VALUE-B</div><div>      my-script -c -d VALUE-D</div><div>    </div><div>    Options:</div><div>      -b VALUE-B  Description</div>

<div>      -d VALUE-D  Description</div></div><div><br></div><div>would be preferred.</div></div></div></div>