Exemplo n.º 1
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"""
    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])
Exemplo n.º 3
0
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])