cea-hpc / clustershell

Scalable cluster administration Python framework — Manage node sets, node groups and execute commands on cluster nodes in parallel.
https://clustershell.readthedocs.io/
425 stars 85 forks source link

migrate to argparse #316

Open thiell opened 8 years ago

thiell commented 8 years ago

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:

Official argparse doc pages:

Tutorial:

Example of argparse implementation I like:

Here argparser created in this tools module actually enables scripts to easily inherit oauth2 options:

from oauth2client import tools

def create_parser():
    parser = argparse.ArgumentParser(add_help=False)
    # add scripts custom options
    #parser.add_argument(...)
    return argparse.ArgumentParser(parents=[tools.argparser, parser])

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 :)).

asteven commented 7 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.

thiell commented 7 years ago

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.

asteven commented 7 years ago

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.