dry4rust/cli/
ignored_command.rs1use std::fmt::Write as _;
7use std::path::Path;
8
9use crate::cli::cli_error::CliResult;
10use crate::cli::command_outcome::CommandOutcome;
11use crate::cli::ignore_entry_line::IgnoreEntryLine;
12use crate::suppression::ignore_file::IgnoreFile;
13
14pub struct IgnoredCommand<'a> {
16 root: &'a Path,
17}
18
19impl<'a> IgnoredCommand<'a> {
20 #[must_use]
21 pub const fn new(root: &'a Path) -> Self {
22 Self { root }
23 }
24
25 pub fn run(&self) -> CliResult<CommandOutcome> {
32 let ignore_file = IgnoreFile::load(self.root);
33 let mut out = String::new();
34 if ignore_file.ignore.is_empty() {
35 let _ = writeln!(out, "No ignored fingerprints.");
36 return Ok(CommandOutcome::succeeded(out));
37 }
38 let _ = writeln!(out, "Ignored fingerprints:");
39 for entry in &ignore_file.ignore {
40 let _ = writeln!(out, "{}", IgnoreEntryLine::new(entry));
41 }
42 Ok(CommandOutcome::succeeded(out))
43 }
44}