def create_parser(self, prog_name, subcommand): cfg = pulsar.Config(apps=['socket', 'pulse'], exclude=['debug'], description=self.help, version=self.get_version()) parser = cfg.parser() for option in self.option_list: flags = [] if option._short_opts: flags.extend(option._short_opts) if option._long_opts: flags.extend(option._long_opts) type = option.type if type == 'choice': type = None s = Setting(option.dest, flags=flags, choices=option.choices, default=option.default, action=option.action, type=type, nargs=option.nargs, desc=option.help) s.add_argument(parser) return parser
def get_parser(self, **params): parser = argparse.ArgumentParser(**params) parser.add_argument('--version', action='version', version=self.get_version(), help="Show version number and exit") config = Setting('config', ('-c', '--config'), default=self.config_module, desc=('python dotted path to a Lux/Pulsar config ' ' file, where settings can be specified.')) config.add_argument(parser, True) for opt in self.default_option_list: opt.add_argument(parser, True) for opt in self.option_list: opt.add_argument(parser, True) return parser