def get_usage(self, context): usage = u" ".join(context.command_path) if self.options: usage += u" " + " ".join(u"[%s]" % option.usage for option in unique(itervalues(self.options))) if self.main_signature and self.main_signature.usage: usage += u" " + self.main_signature.usage return usage
def help(context): """ Show this text. """ print(u"usage: %s" % context.caller.get_usage(context)) if self.description: print() print(self.description) if self.options: print() print(u"options:") for option in unique(itervalues(self.options)): print(u", ".join(option.names)) if option.description: print(u"".join(u" " * 4 + line for line in option.description.splitlines(True))) if self.commands: print() print(u"commands:") for name, command in iteritems(self.commands): print(name) if command.description: print(u" " * 4 + command.description.splitlines()[0]) sys.exit(1)