use clap::Command;
use std::io::Write;

pub fn generate<S: Into<String>>(cmd: &mut Command, bin_name: S, buf: &mut dyn Write) {
    let mut spec: usage::Spec = cmd.clone().into();
    spec.bin = bin_name.into();

    writeln!(buf, "// @generated by usage-cli from clap metadata")
        .expect("write @generated comment");
    writeln!(buf, "{spec}").expect("write usage spec");
}
