html-to-markdown-cli 3.6.0-rc.11

Command-line interface for html-to-markdown - high-performance HTML to Markdown converter
#![allow(clippy::all, clippy::pedantic, clippy::nursery, missing_docs)]

use crate::args::Cli;
use std::fs;
use std::path::PathBuf;

pub fn write_output(output_path: Option<PathBuf>, content: &str) -> Result<(), Box<dyn std::error::Error>> {
    match output_path {
        Some(path) => {
            fs::write(&path, content.as_bytes())
                .map_err(|e| format!("Error writing to file '{}': {}", path.display(), e))?;
        }
        None => {
            print!("{content}");
        }
    }
    Ok(())
}

pub fn output_debug_info(cli: &Cli, msg: &str) {
    if cli.debug {
        eprintln!("{msg}");
    }
}