def main(args=None):
    """Main function for cli."""
    args = get_args(args)

    utils.init_log(args.log_level)

    if ".csv" not in args.input_file.lower():
        logger.warning("Make sure the input file '%s' is in CSV format", args.input_file)

    try:
        records = csvtools.get_imported_data(args.input_file)
    except (EnvironmentError, Dump2PolarionException) as err:
        logger.fatal(err)
        return 1

    # check if all columns required by `pytest_polarion_cfme` are there
    required_columns = {"id": "ID", "title": "Title"}
    missing_columns = [required_columns[k] for k in required_columns if k not in records.results[0]]
    if missing_columns:
        logger.fatal(
            "The input file '%s' is missing following columns: %s",
            args.input_file,
            ", ".join(missing_columns),
        )
        return 1

    try:
        dump2sqlite(records, args.output_file)
    # pylint: disable=broad-except
    except Exception as err:
        logger.exception(err)
        return 1

    return 0