While looking into #258 (use of argparse instead of optparse*), I noticed that:
some of the Cmd subclasses had separate fields for usage and descr_text, but others didn't. So I refactored all Cmd subclasses to have them.
having the subcommand options in an iterable form would be very convenient for use with argparse's subcommand support. Hence, I pulled out the options to a new options field in these classes.
This left much of the get_parser() and description() methods repetitive. By moving ignore_unknown_options to a field as well, I could eliminate all definitions of get_parser and description in favour of methods in the parent Cmd class.
By renaming the cluster_cmds() and node_cmds() functions, I could also do some DRY refactoring in the main ccm script, so there's that as well.
Finally, I added some empty lines here and there to stop flake8 complaining about PEP8 guidelines (2 blank lines after class/function definitions).
While looking into #258 (use of
argparse
instead ofoptparse
*), I noticed that:Cmd
subclasses had separate fields forusage
anddescr_text
, but others didn't. So I refactored allCmd
subclasses to have them.argparse
's subcommand support. Hence, I pulled out the options to a newoptions
field in these classes.This left much of the
get_parser()
anddescription()
methods repetitive. By movingignore_unknown_options
to a field as well, I could eliminate all definitions ofget_parser
anddescription
in favour of methods in the parentCmd
class.By renaming the
cluster_cmds()
andnode_cmds()
functions, I could also do some DRY refactoring in the mainccm
script, so there's that as well.Finally, I added some empty lines here and there to stop
flake8
complaining about PEP8 guidelines (2 blank lines after class/function definitions).Thoughts?
* You can see the WIP state of that here.