def METHOD_NAME(args, error):
    """ Codegen CLI entry point. """
    if args.file_to_touch and not os.path.isfile(args.file_to_touch):
        error("file doesn't exist: " + args.file_to_touch)
    def read_cache_file_lines(filename):
        """
        Yields all lines from the file.
        If the file doesn't exist, a warning is printed.
        """
        try:
            with open(filename, encoding='utf8') as fileobj:
                for line in fileobj:
                    line = line.strip()
                    if line:
                        yield line
        except FileNotFoundError:
            if args.file_to_touch or args.force_rerun_on_generated_list_change:
                print("warning: cache actions were requested, " +
                      "but the target cache could not be read!")
    old_generated = set(read_cache_file_lines(args.generated_list_file))
    old_depends = set(read_cache_file_lines(args.depend_list_file))
    try:
        mode = CodegenMode(args.mode)
    except ValueError as exc:
        error(exc.args[0])
    # arguments are OK.
    # generate sources
    generated, depends = codegen(mode, args.input_dir, args.output_dir)
    def print_set_differences(old, new, name):
        """ Prints the difference between old and new. """
        if old - new:
            print("codegen: removed from " + name + ":\n"
                  "\t" + "\n\t".join(old - new) + "\n")
        if new - old and old:
            print("codegen: new " + name + ":\n"
                  "\t" + "\n\t".join(new - old) + "\n")
    print_set_differences(old_generated, generated, "generated files")
    print_set_differences(old_depends, depends, "dependencies")
    with open(args.generated_list_file, 'w', encoding='utf8') as fileobj:
        fileobj.write('\n'.join(generated))
    with open(args.depend_list_file, 'w', encoding='utf8') as fileobj:
        fileobj.write('\n'.join(depends))
    if args.file_to_touch:
        if old_generated != generated or old_depends != depends:
            os.utime(args.file_to_touch)
    if args.force_rerun_on_generated_list_change:
        if old_generated != generated:
            print("\n\n\n\n"
                  "The list of generated source files has changed.\n"
                  "A build update has been triggered; you need to build "
                  "again.\n"
                  "\n\n\n")
            # fail
            sys.exit(1)