Use consistent naming for the filter file
This commit is contained in:
parent
2995175d03
commit
35e965126b
18
src/main.rs
18
src/main.rs
|
@ -13,23 +13,23 @@ struct Category {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// Get configuration file path
|
// Get filter file path
|
||||||
let config = env::args()
|
let filters = env::args()
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.ok_or_else(|| miette!("Please provide a path to a KDL file with blocked parameters"))?;
|
.ok_or_else(|| miette!("Please provide a path to a KDL file with parameter filters"))?;
|
||||||
|
|
||||||
// Read configurtaion file
|
// Read filter file
|
||||||
let config = fs::read_to_string(&config)
|
let filters = fs::read_to_string(&filters)
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
.map_err(|err| err.context(format!("Could not read file `{config}`")))?;
|
.map_err(|err| err.context(format!("Could not read file `{filters}`")))?;
|
||||||
|
|
||||||
let config = knuffel::parse::<Vec<Category>>("config.kdl", &config)?;
|
let filters = knuffel::parse::<Vec<Category>>("config.kdl", &filters)?;
|
||||||
|
|
||||||
println!("Loaded with categories:");
|
println!("Loaded with categories:");
|
||||||
config.iter().for_each(|v| println!("\t• {}", v.name));
|
filters.iter().for_each(|v| println!("\t• {}", v.name));
|
||||||
|
|
||||||
// Flatten all patterns into a single list, as categories do not matter
|
// Flatten all patterns into a single list, as categories do not matter
|
||||||
let patterns: Vec<String> = config.iter().map(|v| v.params.clone()).flatten().collect();
|
let patterns: Vec<String> = filters.iter().map(|v| v.params.clone()).flatten().collect();
|
||||||
|
|
||||||
// Initialize clipboard context
|
// Initialize clipboard context
|
||||||
let mut clipboard = ClipboardContext::new()
|
let mut clipboard = ClipboardContext::new()
|
||||||
|
|
Loading…
Reference in New Issue