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 fn refresh(&self) {
15 }
17}
18
19pub type SnippetLookup = Arc<dyn SnippetLookupProvider>;
20
21#[derive(Clone)]
22pub struct Config {
23 pub theme: Theme,
25
26 pub audit_path: Option<std::path::PathBuf>,
28
29 pub write: bool,
31
32 pub use_colours: bool,
34
35 pub redact_mode: bool,
37
38 pub redactions: HashSet<ColumnRef>,
40
41 pub snippet_lookup: Option<SnippetLookup>,
43}
44
45impl std::fmt::Debug for Config {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 f.debug_struct("Config")
48 .field("theme", &self.theme)
49 .field("audit_path", &self.audit_path)
50 .field("write", &self.write)
51 .field("use_colours", &self.use_colours)
52 .field("redact_mode", &self.redact_mode)
53 .field("redactions", &self.redactions)
54 .field(
55 "snippet_lookup",
56 &self.snippet_lookup.as_ref().map(|_| "<closure>"),
57 )
58 .finish()
59 }
60}
61
62impl Default for Config {
63 fn default() -> Self {
64 Self {
65 theme: Theme::Dark,
66 audit_path: None,
67 write: false,
68 use_colours: true,
69 redact_mode: false,
70 redactions: HashSet::new(),
71 snippet_lookup: None,
72 }
73 }
74}