Add auto configuration option for example

This commit is contained in:
asonix 2024-02-23 14:10:35 -06:00
parent 6e85a82f42
commit 66858e4d1a

View file

@ -13,8 +13,8 @@ struct Args {
#[clap(long)]
height: u32,
#[clap(long, default_value = "8")]
skip: u32,
#[clap(long)]
skip: Option<u32>,
}
// Example usage:
@ -28,11 +28,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
height,
skip,
} = Args::parse();
let mut encoder = Encoder::new(
Components { x: 4, y: 3 },
ImageBounds { width, height },
skip,
)?;
let mut encoder = if let Some(skip) = skip {
Encoder::new(
Components { x: 4, y: 3 },
ImageBounds { width, height },
skip,
)?
} else {
Encoder::auto(ImageBounds { width, height })
};
let mut stdin = std::io::stdin().lock();
let mut buf = [0u8; 1024];