| 149 | pass |
| 150 | |
| 151 | class OptParseCommand(click.Command): |
| 152 | def __init__(self, name, parser, callback): |
| 153 | super().__init__(name) |
| 154 | self.parser = parser |
| 155 | self.callback = callback |
| 156 | |
| 157 | def parse_args(self, ctx, args): |
| 158 | try: |
| 159 | opts, args = parser.parse_args(args) |
| 160 | except Exception as e: |
| 161 | ctx.fail(str(e)) |
| 162 | ctx.args = args |
| 163 | ctx.params = vars(opts) |
| 164 | |
| 165 | def get_usage(self, ctx): |
| 166 | return self.parser.get_usage() |
| 167 | |
| 168 | def get_help(self, ctx): |
| 169 | return self.parser.format_help() |
| 170 | |
| 171 | def invoke(self, ctx): |
| 172 | ctx.invoke(self.callback, ctx.args, **ctx.params) |
| 173 | |
| 174 | parser = optparse.OptionParser(usage="Usage: foo test [OPTIONS]") |
| 175 | parser.add_option( |
no outgoing calls