Example #1
0
def cmd_help():
    cmds = sys.modules['__main__'].commands
    for c, cmd in cmds.items():
        if isinstance(cmd, dict):
            print log.format_str("{blue}%s{default}" % c)
            for sc, scmd in cmd.items():
                print log.format_str("  {bblue}%s{default}" % (sc))
                doc = scmd.__doc__ and ' '.join(map(str.strip,
                        scmd.__doc__.split('\n'))) or '..'
                print log.format_str("    {bwhite}%s{default}" % doc)
        else:
            print log.format_str("{bblue}%s{default}" % c)
            doc = cmd.__doc__ and ' '.join(map(str.strip,
                    cmd.__doc__.split('\n'))) or '..'
            print log.format_str("    {bwhite}%s{default}" % doc)
Example #2
0
def cmd_help(CMD):
    cmds = sys.modules['__main__'].commands
    if CMD and CMD not in cmds:
        print(sys.modules['__main__'].__doc__.strip())
        print("\nUsage:\n  hier.py help [ %s ]" % " | ".join(cmds.keys()))
    else:
        for c, cmd in cmds.items():
            if CMD and c != CMD:
                continue
            if isinstance(cmd, dict):
                print(log.format_str("{blue}%s{default}" % c))
                for sc, scmd in cmd.items():
                    print(log.format_str("  {bblue}%s{default}" % (sc)))
                    doc = scmd.__doc__ and ' '.join(map(str.strip,
                            scmd.__doc__.split('\n'))) or '..'
                    print(log.format_str("    {bwhite}%s{default}" % doc))
            else:
                print(log.format_str("{bblue}%s{default}" % c))
                doc = cmd.__doc__ and ' '.join(map(str.strip,
                        cmd.__doc__.split('\n'))) or '..'
                print(log.format_str("    {bwhite}%s{default}" % doc))
Example #3
0
 def writeln(self):
     print >>self.out, log.format_str(data)
Example #4
0
 def write(self, data):
     self.out.write(log.format_str(data))
Example #5
0
 def writeln(self):
     print(log.format_str(data), file=self.out)