Esempio n. 1
0
 def __discover_help(self, main_help, parser):
     parser.description = main_help
     subparsers = subparser_choices(parser)
     for choice in sorted(subparsers.keys()):
         parser.description += '\n\n -> \x1b[%sm%s\x1b[0m\n%s' % (
             Logger.LEVELS_COLORS[Logger.L_DEBUG],
             choice, wrap_text(subparsers[choice].description))
Esempio n. 2
0
    def __determine_autocomplete(self, args, logger):
        # bug in python: it will cut out '--' from args:
        if sys.argv[len(sys.argv) - 1] == '--':
            args.input.append('--')

        if len(args.input) > 0: args.input[0] = 'jmake'

        parser = self.main_parser
        free_args = args.input[1:]

        while len(free_args):
            command = free_args[0]
            subparsers = subparser_choices(parser)
            if subparsers and command in subparsers.keys():
                parser = subparsers[command]
                free_args = free_args[1:]
            else:
                break

        result = map_options(parser)
        result.append(['clean'])
        try:
            contributed = parser.autocomplete_contributor()
            if contributed:
                result.append(contributed)
        except AttributeError:
            pass

        flattened_result = (item for group in result for item in group)
        free_size = len(free_args)
        if free_size > 0:
            last_el = free_args[free_size - 1]
            partial_match = last_el if last_el not in flattened_result else None
            filtered_result = (item for group in result if not [x for x in group if x in free_args] for item in group)

            if partial_match is None:
                result = filtered_result
            else:
                result = (o for o in filtered_result if o.startswith(partial_match))
        else:
            result = flattened_result

        return result
Esempio n. 3
0
 def print_autocomplete_help_closure(logger):
     subparser_choices(parser)['auto-complete'].print_help()
     return Callable.success