cargo2meson 0.1.1

generate traits from C header files
Documentation
use std::io::{self, Write as _};

use cargo_metadata::camino::Utf8PathBuf;
use clap::Parser;

/// 1. Read a cargo unit graph from stdin.
/// 2. Remove all build scripts and their ancestors.
/// 3. Emit a meson build script.
#[derive(Parser)]
struct Args {
    /// If provided, remove this prefix from all `src_path`s.
    ///
    /// Useful in conjunction with `cargo vendor`.
    #[arg(long)]
    strip_prefix: Option<Utf8PathBuf>,
}

fn main() -> io::Result<()> {
    let Args { strip_prefix } = Args::parse();
    let mut writer = io::stdout();
    writeln!(
        writer,
        "# this file is @generated by cargo2meson {}\n",
        env!("CARGO_PKG_VERSION")
    )?;
    cargo2meson::mesonify(
        serde_json::from_reader(io::stdin())?,
        strip_prefix
            .map(|it| it.canonicalize_utf8())
            .transpose()?
            .as_deref(),
        writer,
    )
}