2 ms·
Very nice! And especially clever that the DSL is the usage help we all know and love. I'm never happy about the amount of code normally required to write these.
by bajsejohannes 14y ago
Very nice! And especially clever that the DSL is the usage help we all know and love. I'm never happy about the amount of code normally required to write these.
One nitpick is that there is still some repetition: "naval_fate", and well as the long options are repeated. Granted, there might be ways around that which I haven't discovered yet.
- halst 14y agoAbout long options repeated: you can either specify "[options]" shortcut in a pattern in order not to put all options in that pattern, or you can have all options listed in the pattern--then you can avoid having them in option description. About repeating program's name (say "naval_fate"), you can do: """Usage: prog <bla> ... prog <bla> --bla """ args = docopt(__doc__.replace('prog', 'naval_fate'))