formattable 0.2.0

Ergonomically support formatted output
Documentation
use clap::Parser;
use formattable::FormatArgOpt;
use serde::Serialize;

/// Demonstrate how to use `formattable::FormatArgOpt` in a `clap`-based CLI.
///
/// This example just dumps the CLI arguments themselves in the selected format.
#[derive(Debug, Parser, Serialize)]
struct Cli {
    #[clap(flatten)]
    format: FormatArgOpt,
}

fn main() {
    let cli = Cli::parse();
    dbg!(&cli);

    if let Some(format) = *cli.format {
        println!("{}", format.to_string_pretty(&cli).unwrap());
    }
}