Open thiell opened 8 years ago
Why not go with click instead? Have been using this for a while and it's so much nicer then argparse and friends.
Thanks @asteven for the suggestion. I never used click before. I tried to migrate clustershell's cli to argparse with no functional changes but it's tough.
I'm currently more interested in ClusterShell as a library then the cli tools. But if you happen to like click and decide to go with it I may be able to contribute. Thanks for Python3 support btw. Much appreciated.
Migrate to argparse which is more powerful and would provide an easy way to create tools based on the clustershell library. Will also help for Python 3 support (#239).
Usefulness:
-w
/-x
,-b
, ... (#295)nargs='?'
(https://docs.python.org/2/library/argparse.html#nargs), will be useful for--pick
Official argparse doc pages:
Tutorial:
Example of argparse implementation I like:
Here
argparser
created in thistools
module actually enables scripts to easily inherit oauth2 options:The idea is to create a argparser per group of command line options. The obvious one is for manipulating node sets (
-w
/-x
etc.).Note: Before Python 2.7/3.2, python-argparse will become a new dependency, but it is easily available (even available in EPEL5, just saying :)).