use std::fmt::Write as _;
use std::path::Path;
use crate::cli::cli_error::CliResult;
use crate::cli::command_outcome::CommandOutcome;
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) -> CliResult<CommandOutcome> {
let ignore_file = IgnoreFile::load(self.root);
let mut out = String::new();
if ignore_file.ignore.is_empty() {
let _ = writeln!(out, "No ignored fingerprints.");
return Ok(CommandOutcome::succeeded(out));
}
let _ = writeln!(out, "Ignored fingerprints:");
for entry in &ignore_file.ignore {
let _ = writeln!(out, "{}", IgnoreEntryLine::new(entry));
}
Ok(CommandOutcome::succeeded(out))
}
}