def cmd_help(argv, path_to_tx): """List all available commands""" parser = help_parser() (options, args) = parser.parse_args(argv) if len(args) > 1: parser.error("Multiple arguments received. Exiting...") # Get all commands fns = utils.discover_commands() # Print help for specific command if len(args) == 1: try: fns[argv[0]](['--help'], path_to_tx) except KeyError: utils.logger.error("Command %s not found" % argv[0]) # or print summary of all commands # the code below will only be executed if the KeyError exception is thrown # becuase in all other cases the function called with --help will exit # instead of return here keys = fns.keys() keys.sort() logger.info("Transifex command line client.\n") logger.info("Available commands are:") for key in keys: logger.info(" %-15s\t%s" % (key, fns[key].func_doc)) logger.info("\nFor more information run %s command --help" % sys.argv[0])
def cmd_help(argv, path_to_tx): """List all available commands""" parser = help_parser() options = parser.parse_args(argv) # Get all commands fns = utils.discover_commands() # Print help for specific command if options.command: try: fns[options.command](['--help'], path_to_tx) except KeyError: utils.logger.error("Command %s not found" % argv[0]) # or print summary of all commands # the code below will only be executed if the KeyError exception is thrown # because in all other cases the function called with --help will exit # instead of return here keys = list(fns.keys()) keys.sort() print("Transifex command line client.\n") print("Available commands are:") for key in keys: print(" %-15s\t%s" % (key, getattr(fns[key], '__doc__'))) print("\nFor more information run %s command --help" % sys.argv[0])
def cmd_help(argv, path_to_tx): "List all available commands" usage="usage: %prog help command" description="Lists all available commands in the transifex command"\ " client. If a command is specified, the help page of the specific"\ " command is displayed instead." parser = OptionParser(usage=usage, description=description) (options, args) = parser.parse_args(argv) if len(args) > 1: parser.error("Multiple arguments received. Exiting...") # Get all commands fns = utils.discover_commands() # Print help for specific command if len(args) == 1: try: fns[argv[0]](['--help'], path_to_tx) except KeyError: utils.ERRMSG("Command %s not found" % argv[0]) # or print summary of all commands # the code below will only be executed if the KeyError exception is thrown # becuase in all other cases the function called with --help will exit # instead of return here keys = fns.keys() keys.sort() utils.MSG("Transifex command line client.\n") utils.MSG("Available commands are:") for key in keys: utils.MSG(" %-15s\t%s" % (key, fns[key].func_doc)) utils.MSG("\nFor more information run %s command --help" % sys.argv[0])
def cmd_help(argv, path_to_tx): "List all available commands" usage = "usage: %prog help command" description="Lists all available commands in the transifex command"\ " client. If a command is specified, the help page of the specific"\ " command is displayed instead." parser = OptionParser(usage=usage, description=description) (options, args) = parser.parse_args(argv) if len(args) > 1: parser.error("Multiple arguments received. Exiting...") # Get all commands fns = utils.discover_commands() # Print help for specific command if len(args) == 1: try: fns[argv[0]](['--help'], path_to_tx) except KeyError: utils.ERRMSG("Command %s not found" % argv[0]) # or print summary of all commands # the code below will only be executed if the KeyError exception is thrown # becuase in all other cases the function called with --help will exit # instead of return here keys = fns.keys() keys.sort() utils.MSG("Transifex command line client.\n") utils.MSG("Available commands are:") for key in keys: utils.MSG(" %-15s\t%s" % (key, fns[key].func_doc)) utils.MSG("\nFor more information run %s command --help" % sys.argv[0])