Exemple #1
0
    def usage(self):

        rucktalk.message("")
        rucktalk.message("Usage: ruck " + self.name() + " <options> " + \
                       self.arguments())
        rucktalk.message("")

        description = self.description_long() or self.description_short()
        if description:
            description = "'" + self.name() + "': " + description
            for l in ruckformat.linebreak(description, 72):
                rucktalk.message(l)
            rucktalk.message("")

        opts = self.local_opt_table()
        if opts:
            rucktalk.message("'" + self.name() + "' Options:")
            ruckformat.opt_table(opts)
            rucktalk.message("")

        opts = self.default_opt_table()
        if opts:
            rucktalk.message("General Options:")
            ruckformat.opt_table(opts)
            rucktalk.message("")
Exemple #2
0
def print_command_list(commands, with_categories=0):

    max_len = 0
    cmd_list = []

    for c in commands:
        name, aliases, description, category = c

        if aliases:
            name = name + " (" + string.join(aliases, ", ") + ")"

        cmd_list.append([name, description, category])
        max_len = max(max_len, len(name))

    desc_len = max_len + 4

    cmd_list.sort(command_sort)

    previous_category = "we will banish all dwarves from the love kingdom"

    for c in cmd_list:

        name, description, category = c

        if with_categories and category != previous_category:
            if category_data.has_key(category):
                category_name = category_data[category][0]
            else:
                category_name = string.upper(category[0]) + category[1:]

            rucktalk.message("\n" + category_name + " commands:")
            previous_category = category

        # If, for some reason, the command list is *really* wide (which it never should
        # be), don't do something stupid.
        if 79 - desc_len > 10:
            desc = ruckformat.linebreak(description, 79-desc_len)
        else:
            desc = [description]

        desc_first = desc.pop(0)
        rucktalk.message("  " + string.ljust(name, max_len) + "  " + desc_first)
        for d in desc:
            rucktalk.message(" " * desc_len + d)