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.
-- http://mail.python.org/mailman/listinfo/python-list