| http://hg.logilab.org/logilab/common/rev/2029eb2dd071 |
| |
| --- optparser.py |
| +++ optparser.py |
| @@ -46,11 +46,11 @@ |
| self.min_args, self.max_args = 0, 1 |
| |
| def add_command(self, name, mod_or_funcs, help=''): |
| - """name of the command |
| - name of module or tuple of functions (run, add_options) |
| - """ |
| + """name of the command, name of module or tuple of functions |
| + (run, add_options) |
| + """ |
| assert isinstance(mod_or_funcs, str) or isinstance(mod_or_funcs, tuple), \ |
| - "mod_or_funcs has to be a module name or a tuple of functions" |
| + "mod_or_funcs has to be a module name or a tuple of functions" |
| self._commands[name] = (mod_or_funcs, help) |
| |
| def print_main_help(self): |
| @@ -64,7 +64,7 @@ |
| self.print_main_help() |
| sys.exit(1) |
| cmd = args[0] |
| - args = args[1:] |
| + args = args[1:] |
| if cmd not in self._commands: |
| if cmd in ('-h', '--help'): |
| self.print_main_help() |
| @@ -79,8 +79,8 @@ |
| self.description = help |
| if isinstance(mod_or_f, str): |
| exec 'from %s import run, add_options' % mod_or_f |
| - else: |
| - run, add_options = mod_or_f |
| + else: |
| + run, add_options = mod_or_f |
| add_options(self) |
| (options, args) = self.parse_args(args) |
| if not (self.min_args <= len(args) <= self.max_args): |