1use std::{collections::HashSet, sync::Arc};
2
3use crate::{column_extractor::ColumnRef, theme::Theme};
4
5pub trait SnippetLookupProvider: Send + Sync {
6 fn lookup(&self, name: &str) -> Option<String>;
7 fn list_names(&self) -> Vec<String> {
8 Vec::new()
9 }
10 fn get_description(&self, name: &str) -> Option<String> {
11 let _ = name;
12 None
13 }
14}
15
16pub type SnippetLookup = Arc<dyn SnippetLookupProvider>;
17
18#[derive(Clone)]
19pub struct Config {
20 pub theme: Theme,
22
23 pub audit_path: Option<std::path::PathBuf>,
25
26 pub write: bool,
28
29 pub use_colours: bool,
31
32 pub redact_mode: bool,
34
35 pub redactions: HashSet<ColumnRef>,
37
38 pub snippet_lookup: Option<SnippetLookup>,
40}
41
42impl std::fmt::Debug for Config {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 f.debug_struct("Config")
45 .field("theme", &self.theme)
46 .field("audit_path", &self.audit_path)
47 .field("write", &self.write)
48 .field("use_colours", &self.use_colours)
49 .field("redact_mode", &self.redact_mode)
50 .field("redactions", &self.redactions)
51 .field(
52 "snippet_lookup",
53 &self.snippet_lookup.as_ref().map(|_| "<closure>"),
54 )
55 .finish()
56 }
57}
58
59impl Default for Config {
60 fn default() -> Self {
61 Self {
62 theme: Theme::Dark,
63 audit_path: None,
64 write: false,
65 use_colours: true,
66 redact_mode: false,
67 redactions: HashSet::new(),
68 snippet_lookup: None,
69 }
70 }
71}