def main(): logger.debug("sys args %s" % sys.argv) parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest="command") for name, func in commands.items(): sb = subparsers.add_parser(name, help=func.__doc__) for argspec in func.args: name, defaults = argspec nargs = None if defaults is None else argparse.OPTIONAL sb.add_argument(name, nargs=nargs, type=str) for option in func.options: name, nargs, description,option_type = option if nargs == 0: sb.add_argument('--'+name, action='store_true', help=description, dest="options."+name) else: sb.add_argument('--'+name, nargs=nargs, help=description, type=option_type, dest="options."+name) args = vars(parser.parse_args()) cmd = args.pop('command') options = {} for k in list(args.keys()): if k.startswith('options.'): v = args.pop(k) k = k[k.index('.')+1:] options[k] = v if options: args['options'] = options logger.debug(args) commands[cmd](**args)
def add_repos(self, name, uri, repos_type, order=None): if repos_type == 'local': repo = MavenFileSystemRepos(name, uri) elif repos_type == 'remote': repo = MavenHttpRemoteRepos(name, uri) else: logger.warn('[Error] Unknown repository type.') sys.exit(1) if repo not in self.repos: if order is not None: self.repos.insert(order, repo) else: self.repos.append(repo) logger.debug('[Repository] Added: %s' % repo.name)