You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
517 B
13 lines
517 B
import argparse |
|
|
|
|
|
class BaseParser: |
|
def __init__(self, command): |
|
self.arg_parser = argparse.ArgumentParser(command, add_help=False) |
|
self.subparser = self.arg_parser.add_subparsers(dest='{}_subcommand'.format(command)) |
|
self.common_args = {'add_help': False} |
|
|
|
methods = [attr for attr in dir(self) if not attr.startswith('__') |
|
and type(getattr(self, attr)).__name__ == 'method'] |
|
for method in methods: |
|
getattr(self, method)(**self.common_args)
|
|
|