formattable 0.2.0

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

/// Demonstrate how to use `formattable` in a `clap`-based CLI.
///
/// This example just dumps the CLI arguments themselves as the selected format.
#[derive(Debug, Parser, Serialize)]
struct Cli {
    /// Select a format for output.
    #[clap(short, long, value_enum, default_value_t = Format::Json)]
    format: Format,
}

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

    println!("{}", cli.format.to_string_pretty(&cli).unwrap());
}