def METHOD_NAME(argv=None, stdout=None, stdin=None, HTML=HTML):
    """The ``weasyprint`` program takes at least two arguments:
    .. code-block:: sh
        weasyprint [options] <input> <output>
    """
    args = PARSER.parse_args(argv)
    if args.input == '-':
        source = stdin or sys.stdin.buffer
        if args.base_url is None:
            args.base_url = '.'  # current directory
        elif args.base_url == '':
            args.base_url = None  # no base URL
    else:
        source = args.input
    if args.output == '-':
        output = stdout or sys.stdout.buffer
    else:
        output = args.output
    # TODO: to be removed when --optimize-size is removed
    optimize_size = {'fonts', 'hinting', 'pdf'}
    if args.optimize_size is not None:
        warn(
            'The --optimize-size option is now deprecated '
            'and will be removed in next version. '
            'Please use the other options available in --help instead.',
            category=FutureWarning)
        for arg in args.optimize_size:
            if arg == 'none':
                optimize_size.clear()
            elif arg == 'all':
                optimize_size |= {'images', 'fonts', 'hinting', 'pdf'}
            else:
                optimize_size.add(arg)
    del args.optimize_size
    options = vars(args)
    # TODO: to be removed when --optimize-size is removed
    if 'images' in optimize_size:
        options['optimize_images'] = True
    if 'fonts' not in optimize_size:
        options['full_fonts'] = True
    if 'hinting' not in optimize_size:
        options['hinting'] = True
    if 'pdf' not in optimize_size:
        options['uncompressed_pdf'] = True
    # Default to logging to stderr.
    if args.debug:
        LOGGER.setLevel(logging.DEBUG)
    elif args.verbose:
        LOGGER.setLevel(logging.INFO)
    if not args.quiet:
        handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
        LOGGER.addHandler(handler)
    html = HTML(
        source, base_url=args.base_url, encoding=args.encoding,
        media_type=args.media_type)
    html.write_pdf(output, **options)