Exemplo n.º 1
0
def HandleCommandlineArguments():
    print("FUDD - BIFF Save File Editor Version " + VersionMgr.ReadVer())

    if sys.version_info < (3, 3):
        print("---- Error: Required Python 3.3 or greater ---")
        return False

    parser = argparse.ArgumentParser(description='FUDD the fearful')

    parser.add_argument("-i",
                        "--input",
                        help='specifies application configuration file file',
                        type=str,
                        required=True)
    parser.add_argument("-o",
                        "--output",
                        help='specifies file to generate',
                        type=str,
                        required=True)
    parser.add_argument("-l",
                        "--logfile",
                        help='specifies log file name',
                        type=str)
    parser.add_argument("-v",
                        "--verbose",
                        help="prints debug information",
                        action="store_true")

    try:
        args = parser.parse_args()

    except:
        return False

    if None != args.logfile:
        Log.setLogfile(args.logfile)

    if False == args.verbose:
        Log.setLevel(logging.ERROR)

    else:
        Log.setLevel(logging.INFO)

    Log.getLogger().info("")

    ReadConfigFile(args.input, args.output)
Exemplo n.º 2
0
def HandleCommandlineArguments():
    print("FUDD - BIFF Save File Editor Version " + VersionMgr.ReadVer())

    if sys.version_info < (3, 3):
        print("---- Error: Required Python 3.3 or greater ---")
        return False

    firstLevelActionNames, firstLevelActions = SetupActions()
    parser = argparse.ArgumentParser(description='FUDD the Elmer',
                                     add_help=False)

    parser.add_argument("-i",
                        "--input",
                        help='specifies input file(s), wildcards allowed',
                        type=str,
                        required=True)
    parser.add_argument(
        "-o",
        "--output",
        help='specifies file to generate, wildcards allowed in most cases',
        type=str,
        required=True)
    parser.add_argument(
        '-a',
        '--action',
        help='action to perform',
        required=True,
        nargs="?",
        choices=firstLevelActionNames,
    )

    parser.add_argument("-y",
                        "--overwrite",
                        help="will not prompt if overwriting target",
                        action="store_true")
    parser.add_argument("-l",
                        "--logfile",
                        help='specifies log file name',
                        type=str)
    parser.add_argument("-v",
                        "--verbose",
                        help="prints debug information",
                        action="store_true")
    parser.add_argument('-h', '--help', action='store_true')

    try:
        global g_args
        g_args, sub_args = parser.parse_known_args()

        # Manually handle help
        if len(sub_args) < 1:
            print(parser.format_help())
            sys.exit(1)
        # Otherwise pass the help option on to the subcommand
        if g_args.help:
            sub_args.append('--help')

    except:
        return False

    if None != g_args.logfile:
        Log.setLogfile(g_args.logfile)

    if False == g_args.verbose:
        Log.setLevel(logging.ERROR)

    else:
        Log.setLevel(logging.INFO)

    parseAndRunAction(g_args.action, firstLevelActions.getActionList(),
                      sub_args)