h3o_cli/commands/
compress.rs

1//! Expose [`h3o_zip::compress`]
2
3use anyhow::{Context, Result as AnyResult};
4use clap::Parser;
5use std::io;
6
7/// Compress the given set of indexes (from stdin).
8#[derive(Parser, Debug)]
9pub struct Args;
10
11/// Run the `compact` command.
12pub fn run(_args: &Args) -> AnyResult<()> {
13    let mut indexes =
14        crate::io::read_cell_indexes().collect::<AnyResult<Vec<_>>>()?;
15    indexes.sort_unstable();
16
17    let mut stdout = io::stdout().lock();
18    h3o_zip::compress(&mut stdout, indexes).context("compression")?;
19
20    Ok(())
21}