Esempio n. 1
0
        return self.__collector

    @classmethod
    def _print_subcommands_for(cls, cmd):
        if not isinstance(cmd, CommandContainer):
            return
        for subcommand_name in iter(sorted(cmd.get_command_names())):
            print "    %s - %s" % (subcommand_name, cmd.get_command(subcommand_name).description)


    def _process_subcommands_for(self, cmd, parent_name):

        for subcommand_name in iter(sorted(cmd.get_command_names())):
            subcmd = cmd.get_command(subcommand_name)

            if not isinstance(subcmd, CommandContainer):
                continue
            print "\n  Command '%s %s':" % (parent_name, subcommand_name)
            self._print_subcommands_for(subcmd)
            self._process_subcommands_for(subcmd, parent_name+" "+subcommand_name)

    def print_usage(self, command="katello"):
        print "  Possible commands:"
        self._print_subcommands_for(self.__collector)
        self._process_subcommands_for(self.__collector, command)

if __name__ == "__main__":
    usage_gen = UsageGenerator()
    setup_admin(usage_gen.collector(), sys.argv[1])
    usage_gen.print_usage(sys.argv[1])
        commands = []
        for subcommand_name in iter(sorted(container.get_command_names())):

            subcmd = container.get_command(subcommand_name)

            cmd = Command(subcommand_name, subcmd.description)

            if isinstance(subcmd, CommandContainer):
                subcommands = self._convert_commands(subcmd)
                for subcommand in subcommands:
                    cmd.add_subcommand(subcommand)

            # get options
            parser = FakeParser()
            subcmd.setup_parser(parser)

            for op in parser.options:
                description = op[1].get('help', '')
                required = '(required)' in description
                cmd.add_option(Option(list(op[0]), description, required=required, dest=op[1].get('dest', None)))
            commands.append(cmd)
        return commands


if __name__ == "__main__":
    container = CommandContainer()
    setup_admin(container, sys.argv[1])
    commands = KatelloBridgeGenerator(container).commands()
    print json.dumps(commands, sort_keys=True, cls=CustomJSONEncoder, separators=(',', ': '), indent=2)

Esempio n. 3
0
        return self.__collector

    @classmethod
    def _print_subcommands_for(cls, cmd):
        if not isinstance(cmd, CommandContainer):
            return
        for subcommand_name in iter(sorted(cmd.get_command_names())):
            print "    %s - %s" % (subcommand_name, cmd.get_command(subcommand_name).description)


    def _process_subcommands_for(self, cmd, parent_name):

        for subcommand_name in iter(sorted(cmd.get_command_names())):
            subcmd = cmd.get_command(subcommand_name)

            if not isinstance(subcmd, CommandContainer):
                continue
            print "\n  Command '%s %s':" % (parent_name, subcommand_name)
            self._print_subcommands_for(subcmd)
            self._process_subcommands_for(subcmd, parent_name+" "+subcommand_name)

    def print_usage(self):
        print "  Possible commands:"
        self._print_subcommands_for(self.__collector)
        self._process_subcommands_for(self.__collector, "katello")

if __name__ == "__main__":
    usage_gen = UsageGenerator()
    setup_admin(usage_gen.collector())
    usage_gen.print_usage()
Esempio n. 4
0
    @classmethod
    def _print_subcommands_for(cls, cmd):
        if not isinstance(cmd, CommandContainer):
            return
        for subcommand_name in iter(sorted(cmd.get_command_names())):
            print "    %s - %s" % (
                subcommand_name, cmd.get_command(subcommand_name).description)

    def _process_subcommands_for(self, cmd, parent_name):

        for subcommand_name in iter(sorted(cmd.get_command_names())):
            subcmd = cmd.get_command(subcommand_name)

            if not isinstance(subcmd, CommandContainer):
                continue
            print "\n  Command '%s %s':" % (parent_name, subcommand_name)
            self._print_subcommands_for(subcmd)
            self._process_subcommands_for(subcmd,
                                          parent_name + " " + subcommand_name)

    def print_usage(self, command="katello"):
        print "  Possible commands:"
        self._print_subcommands_for(self.__collector)
        self._process_subcommands_for(self.__collector, command)


if __name__ == "__main__":
    usage_gen = UsageGenerator()
    setup_admin(usage_gen.collector(), sys.argv[1])
    usage_gen.print_usage(sys.argv[1])
Esempio n. 5
0
    def _print_subcommands_for(self, cmd):
        if not isinstance(cmd, CommandContainer):
            return
        for subcommand_name in iter(sorted(cmd.get_command_names())):
            print "    %s - %s" % (
                subcommand_name, cmd.get_command(subcommand_name).description)

    def _process_subcommands_for(self, cmd, parent_name):

        for subcommand_name in iter(sorted(cmd.get_command_names())):
            subcmd = cmd.get_command(subcommand_name)

            if not isinstance(subcmd, CommandContainer):
                continue
            print "\n  Command '%s %s':" % (parent_name, subcommand_name)
            self._print_subcommands_for(subcmd)
            self._process_subcommands_for(subcmd,
                                          parent_name + " " + subcommand_name)

    def print_usage(self):
        print "  Possible commands:"
        self._print_subcommands_for(self.__collector)
        self._process_subcommands_for(self.__collector, "katello")


if __name__ == "__main__":
    usage_gen = UsageGenerator()
    setup_admin(usage_gen.collector())
    usage_gen.print_usage()