use std::collections::HashSet;
use anyhow::Result;
use bc_envelope::prelude::*;
use clap::Args;
#[derive(Debug, Args)]
#[group(skip)]
pub struct CommandArgs {
#[arg(long)]
elided: bool,
#[arg(long)]
encrypted: bool,
#[arg(long)]
compressed: bool,
}
impl CommandArgs {
pub fn exec_with_envelope_and_target(
&self,
envelope: Envelope,
target: Option<HashSet<Digest>>,
) -> Result<String> {
let mut obscure_types = Vec::new();
if self.elided {
obscure_types.push(ObscureType::Elided);
}
if self.encrypted {
obscure_types.push(ObscureType::Encrypted);
}
if self.compressed {
obscure_types.push(ObscureType::Compressed);
}
let digests = envelope.nodes_matching(target.as_ref(), &obscure_types);
super::output_digests(digests)
}
}