use malwaredb_server::State;
use std::process::ExitCode;
use clap::{Args, Subcommand};
#[derive(Clone, Debug, Args, PartialEq)]
pub struct Compression {
#[clap(subcommand)]
option: Option<Options>,
}
#[derive(Clone, Debug, Subcommand, PartialEq, Eq)]
enum Options {
Enable,
Disable,
}
impl Compression {
pub async fn execute(&self, state: State) -> anyhow::Result<ExitCode> {
match self.option {
None => {
let compression_state = if state.db_config.compression {
"enabled"
} else {
"disabled"
};
println!("Compression {compression_state}");
}
Some(Options::Enable) => {
state.db_type.enable_compression().await?;
println!(
"Compression flag set. Please restart Malware DB for this change to take effect."
);
}
Some(Options::Disable) => {
state.db_type.enable_compression().await?;
println!(
"Compression flag unset. Please restart Malware DB for this change to take effect."
);
}
}
Ok(ExitCode::SUCCESS)
}
}