use std::io::Write;
use std::path::Path;
use crate::cli::cli_error::CliResult;
use crate::cli::ignore_entry_line::IgnoreEntryLine;
use crate::suppression::ignore_file::IgnoreFile;
pub struct IgnoredCommand<'a> {
root: &'a Path,
}
impl<'a> IgnoredCommand<'a> {
#[must_use]
pub const fn new(root: &'a Path) -> Self {
Self { root }
}
pub fn run(&self, writer: &mut impl Write) -> CliResult {
let ignore_file = IgnoreFile::load(self.root);
if ignore_file.ignore.is_empty() {
writeln!(writer, "No ignored fingerprints.")?;
return Ok(());
}
writeln!(writer, "Ignored fingerprints:")?;
for entry in &ignore_file.ignore {
writeln!(writer, "{}", IgnoreEntryLine::new(entry))?;
}
Ok(())
}
}