I did not know about docopt. It is basically the same idea of this recipe I
wrote about 12 years ago:
https://code.activestate.com/recipes/278844-parsing-the-command-line/?in=user-1122360
Good that it was reinvented :-)
--
https://mail.python.org/mailman/listinfo/python-list
> Not sure if this fits the bill, or makes sense here, but I came cross
> "docopt" which touts itself as a "Command-line interface description
> language". I used it in a project and it seems to be pretty easy to use
> as well as elegant. It stores the arguments & values as a dictionary,
> keyed by
On Monday 27 June 2016 06:28 AM, Steven D'Aprano wrote:
> On Monday 27 June 2016 15:34, Lawrence D’Oliveiro wrote:
>
>> On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
>>
>>> # Set verbose flag
>>> verbose = False
>>> if arguments['--verbose']:
>>> verbose = True
>>> elif arg
On Monday 27 June 2016 15:34, Lawrence D’Oliveiro wrote:
> On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
>
>> # Set verbose flag
>> verbose = False
>> if arguments['--verbose']:
>> verbose = True
>> elif arguments['-q']:
>> verbose = False
>
> Don’t you just love code
On Monday, June 27, 2016 at 4:56:10 PM UTC+12, Sachin Garg wrote:
> # Set verbose flag
> verbose = False
> if arguments['--verbose']:
> verbose = True
> elif arguments['-q']:
> verbose = False
Don’t you just love code (and commenting) like this...
--
https://mail.python.org/mailman/listi
On Sunday 26 June 2016 02:51 PM, Joseph L. Casale wrote:
> I have some code where sys.argv is sliced up and manually fed to discrete
> argparse
> instances each with a single subparser. The reason the discrete parsers all
> having a
> single subparser was to make handling the input simpler, the f
On Monday, June 27, 2016 at 6:56:41 AM UTC+12, Joseph L. Casale wrote:
> This has become unmaintainable as the manual slicing is always subject
> to a new case by where a parser has a positional, switch or optional
> parameter for example. Also, since argv is grouped by subparser
> specifiers, if a
I have some code where sys.argv is sliced up and manually fed to discrete
argparse
instances each with a single subparser. The reason the discrete parsers all
having a
single subparser was to make handling the input simpler, the first arg in the
slice
could be left in.
This has become unmaintai