def parse_args():
    """
    Parse the command line arguments
    """
    global default_device

    parser = argparse.ArgumentParser(description = 'Initialize OATH token for use with yhsm-validation-server',
                                     add_help=True,
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter,
                                     )
    parser.add_argument('-D', '--device',
                        dest='device',
                        default=default_device,
                        required=False,
                        help='YubiHSM device',
                        )
    parser.add_argument('-v', '--verbose',
                        dest='verbose',
                        action='store_true', default=False,
                        help='Enable verbose operation',
                        )
    parser.add_argument('--debug',
                        dest='debug',
                        action='store_true', default=False,
                        help='Enable debug operation',
                        )
    parser.add_argument('--force',
                        dest='force',
                        action='store_true', default=False,
                        help='Overwrite any present entry',
                        )
    parser.add_argument('--key-handle',
                        dest='key_handle',
                        required=True,
                        help='Key handle to create AEAD',
                        metavar='HANDLE',
                        )
    parser.add_argument('--uid',
                        dest='uid',
                        required=True,
                        help='User ID',
                        metavar='STR',
                        )
    parser.add_argument('--oath-c',
                        dest='oath_c',
                        required=False,
                        default = 0,
                        help='Initial OATH counter value',
                        metavar='INT',
                        )
    parser.add_argument('--test-oath-window',
                        dest='look_ahead',
                        required=False,
                        default = 10,
                        help='Number of codes to search with --test-code',
                        metavar='INT',
                        )
    parser.add_argument('--test-code',
                        dest='test_code',
                        type=int, required=False,
                        help='Optional OTP from token for verification',
                        metavar='INT',
                        )
    parser.add_argument('--oath-k',
                        dest='oath_k',
                        required=False,
                        help='The secret key of the token, hex encoded',
                        metavar='HEXSTR',
                        )
    parser.add_argument('--db-file',
                        dest='db_file',
                        default=default_db_file,
                        required=False,
                        help='DB file for storing AEAD\'s for --pwhash and --oath in the yhsm-validation-server',
                        metavar='FN',
                        )

    args = parser.parse_args()
    return args
Parse the command line arguments