1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Expose [`h3o_zip::compress`]

use anyhow::{Context, Result as AnyResult};
use clap::Parser;
use std::io;

/// Compress the given set of indexes (from stdin).
#[derive(Parser, Debug)]
pub struct Args;

/// Run the `compact` command.
pub fn run(_args: &Args) -> AnyResult<()> {
    let mut indexes =
        crate::io::read_cell_indexes().collect::<AnyResult<Vec<_>>>()?;
    indexes.sort_unstable();

    let mut stdout = io::stdout().lock();
    h3o_zip::compress(&mut stdout, indexes).context("compression")?;

    Ok(())
}