Created
March 15, 2018 02:49
-
-
Save nnarain/31baae164bcde75e75e2d01e56259b1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myplugins import BasePlugin | |
from argparse import ArgumentParser | |
class Plugin1(BasePlugin): | |
def __init__(self): | |
BasePlugin.__init__(self, 'plugin1') | |
def init_parser(self, parser): | |
parser.add_argument('-t', '--topics') | |
class Plugin2(BasePlugin): | |
def __init__(self): | |
BasePlugin.__init__(self, 'plugin2') | |
def init_parser(self, parser): | |
parser.add_argument('-s', '--start') | |
parser.add_argument('-e', '--end') | |
def main(): | |
plugins = [ | |
Plugin1(), | |
Plugin2() | |
] | |
parser = ArgumentParser(description='plugins', add_help=False) | |
subparsers = parser.add_subparsers() | |
for plugin in plugins: | |
subparser = subparsers.add_parser(plugin.name, parents=[parser]) | |
plugin.init_parser(subparser) | |
args = vars(parser.parse_args()) | |
print (args) | |
if __name__ == '__main__': | |
# parser = ArgumentParser(description = "Setup the DB", add_help=False) | |
# subparsers = parser.add_subparsers() | |
# drop_parser = subparsers.add_parser('drop', parents=[parser]) | |
# drop_parser.add_argument('-dataset-name', required=True,type = str, help = "Dataset Name",default = None) | |
# print (vars(parser.parse_args())) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment