pub mod bun;
pub mod cargo;
pub mod generic;
pub mod git;
pub mod npm;
pub mod pnpm;
pub mod pytest;
pub mod tsc;
use crate::context::AppContext;
use bun::BunCompressor;
use cargo::CargoCompressor;
use generic::{strip_ansi, GenericCompressor};
use git::GitCompressor;
use npm::NpmCompressor;
use pnpm::PnpmCompressor;
use pytest::PytestCompressor;
use tsc::TscCompressor;
pub trait Compressor {
fn matches(&self, command: &str) -> bool;
fn compress(&self, command: &str, output: &str) -> String;
}
pub fn compress(command: &str, output: String, ctx: &AppContext) -> String {
if !ctx.config().experimental_bash_compress {
return output;
}
let stripped = strip_ansi(&output);
let compressors: [&dyn Compressor; 7] = [
&GitCompressor,
&CargoCompressor,
&TscCompressor,
&NpmCompressor,
&BunCompressor,
&PnpmCompressor,
&PytestCompressor,
];
for compressor in compressors {
if compressor.matches(command) {
return compressor.compress(command, &stripped);
}
}
GenericCompressor.compress(command, &stripped)
}