def parse_arguments():
    'Sets up and parses command-line arguments.\n\n    Returns:\n        log_level: A logging level to filter log output.\n        directory: The directory to search for .cmd files.\n        output: Where to write the compile-commands JSON file.\n    '
    usage = 'Creates a compile_commands.json database from kernel .cmd files'
    parser = argparse.ArgumentParser(description=usage)
    directory_help = 'Path to the kernel source directory to search (defaults to the working directory)'
    parser.add_argument('-d', '--directory', type=str, help=directory_help)
    output_help = 'The location to write compile_commands.json (defaults to compile_commands.json in the search directory)'
    parser.add_argument('-o', '--output', type=str, help=output_help)
    log_level_help = (((('The level of log messages to produce (one of ' + ', '.join(_VALID_LOG_LEVELS)) + '; defaults to ') + _DEFAULT_LOG_LEVEL) + ')')
    parser.add_argument('--log_level', type=str, default=_DEFAULT_LOG_LEVEL, help=log_level_help)
    args = parser.parse_args()
    log_level = args.log_level
    if (log_level not in _VALID_LOG_LEVELS):
        raise ValueError(('%s is not a valid log level' % log_level))
    directory = (args.directory or os.getcwd())
    output = (args.output or os.path.join(directory, _DEFAULT_OUTPUT))
    directory = os.path.abspath(directory)
    return (log_level, directory, output)
Sets up and parses command-line arguments.

Returns:
    log_level: A logging level to filter log output.
    directory: The directory to search for .cmd files.
    output: Where to write the compile-commands JSON file.
def parse_arguments():
    'Sets up and parses command-line arguments.\n\n    Returns:\n        log_level: A logging level to filter log output.\n        directory: The directory to search for .cmd files.\n        output: Where to write the compile-commands JSON file.\n    '
    usage = 'Creates a compile_commands.json database from kernel .cmd files'
    parser = argparse.ArgumentParser(description=usage)
    directory_help = 'Path to the kernel source directory to search (defaults to the working directory)'
    parser.add_argument('-d', '--directory', type=str, help=directory_help)
    output_help = 'The location to write compile_commands.json (defaults to compile_commands.json in the search directory)'
    parser.add_argument('-o', '--output', type=str, help=output_help)
    log_level_help = (((('The level of log messages to produce (one of ' + ', '.join(_VALID_LOG_LEVELS)) + '; defaults to ') + _DEFAULT_LOG_LEVEL) + ')')
    parser.add_argument('--log_level', type=str, default=_DEFAULT_LOG_LEVEL, help=log_level_help)
    args = parser.parse_args()
    log_level = args.log_level
    if (log_level not in _VALID_LOG_LEVELS):
        raise ValueError(('%s is not a valid log level' % log_level))
    directory = (args.directory or os.getcwd())
    output = (args.output or os.path.join(directory, _DEFAULT_OUTPUT))
    directory = os.path.abspath(directory)
    return (log_level, directory, output)