def show_help(commands): print("CloudMapper {}".format(__version__)) print("usage: {} [{}] [...]".format(sys.argv[0], "|".join(sorted(commands.keys())))) for command, module in sorted(commands.items()): print(" {}: {}".format(command, module.__description__)) exit(-1)
def check_message(message): global commands if isinstance(message,dict): command = message.get('command',None) print command if (command not in commands.keys()): return False ID = message.get('ID',None) if not ID: return False arguments = message.get('arguments',None) nb_of_arguments = commands[command].get('nb_of_arguments',0) if not arguments and nb_of_arguments == 0: return True elif not arguments and nb_of_arguments != 0: return False else: # Check if the message has the valid number of arguments if len(arguments) != nb_of_arguments: return False # Check if there is any constraint constraint = commands[command].get('constraint',False) if constraint != False: print constraint(arguments) if constraint(arguments): return True else: return False else: return True else: return False
def consume(): key = config.popArg(1) if commands.knows(key): commands.help(key) return print("""\ Usage: owifc COMMAND [OPTION ...] Known COMMANDs are: """) for key in commands.keys(): print(key + " " + "." * (16 - len(key)) + " " + commands.describe(key)) print(""" You can type "owifc help COMMAND" for more information. Common OPTIONs are: (--host | -h) HOST ................... The host of your OpenWebif Server. (--bouquet | -b) BOUQUET ............. The bouquet. --email-to address ................... Email the result to the specified address. --smtp username:password@host:port ... The SMTP server for sending mails. --smtps username:password@host:port .. The secure SMTP server for sending mails. --skip-notified ...................... Report programs only once. (--file | -f) FILE ................... Read the params from the file (line by line). (--pretty | -p) ...................... Pretty print. (--debug | -X) ....................... Enable debug output. If the bouquet is omnitted, it uses the first (default) one. """)
def getLDIF(self): my_ldif = [] commands = {} aliases = self.sp.cmndAliases.keys() for cmndAlias in self.sp.cmndAliases: if(cmndAlias == self.command): for cmd in self.sp.cmndAliases[cmndAlias]: commands[cmd] = 1 elif self.command not in aliases: commands[self.command] = 1 if self.runas and self.runas not in ["ANY", "ALL"]: my_ldif.append("sudoRunas: %s" % self.runas) if not self.passwd: my_ldif.append("sudoOption: !authenticate") for command in commands.keys(): my_ldif.append("sudoCommand: %s" % command) return my_ldif
def getLDIF(self): my_ldif = [] commands = {} aliases = self.sp.cmndAliases.keys() for cmndAlias in self.sp.cmndAliases: if (cmndAlias == self.command): for cmd in self.sp.cmndAliases[cmndAlias]: commands[cmd] = 1 elif self.command not in aliases: commands[self.command] = 1 if self.runas and self.runas not in ["ANY", "ALL", "ALL*ALL"]: my_ldif.append("sudoRunas: %s" % self.runas) if not self.passwd: my_ldif.append("sudoOption: !authenticate") for command in commands.keys(): my_ldif.append("sudoCommand: %s" % command) return my_ldif
notifications issues per repo globally assigned to me / open / etc. followers following leaders disciples ls ls [user|org|issues]? """ if __name__ == '__main__': parsers = {} parser = argparse.ArgumentParser() ghconfig.add_config_to_parser(parser) subparsers = parser.add_subparsers(help='sub-command help') for k in commands: parsers[k] = subparsers.add_parser(k) # will buy beer for anyone to show me how to do this better. cmd = set(commands.keys()).intersection(sys.argv) if not cmd or len(cmd) > 1: parser.parse_args() else: cmd = cmd.pop() commands[cmd](parser, parsers[cmd])
tokens = user_input.split() if len(tokens)==0: continue cmd = tokens[0] arg = tokens[1] if len(tokens)>1 else None # exits from the application if cmd == 'quit': break # prints out all available commands if cmd == 'help': print INFO print 'Commands: \n%s' % commands.keys() continue # man prints out the doc string to provide the user with some help if cmd == 'man': if arg in commands: print commands[arg].__doc__.rstrip()[1:] else: print 'Unknown command specified for man pages' continue # Execute the specified command with the argument if cmd in commands: commands[cmd](notebook, arg) else: print 'Unknown command specified.\nAccepted commands = %s' % commands.keys()