Implement keywords_file option
Signed-off-by: hr567 <hr567@hr567.me>
This commit is contained in:
parent
1727bd8e6e
commit
caafa8f715
@ -30,7 +30,14 @@ struct Args {
|
|||||||
keywords: Vec<String>,
|
keywords: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ARGS: Lazy<Args> = Lazy::new(Args::parse);
|
static ARGS: Lazy<Args> = Lazy::new(|| {
|
||||||
|
let mut args = Args::parse();
|
||||||
|
if let Some(keywords_file) = args.keywords_file.take() {
|
||||||
|
let content = std::fs::read_to_string(keywords_file).expect("failed to read keywords file");
|
||||||
|
args.keywords.extend(content.lines().map(|s| s.to_string()));
|
||||||
|
}
|
||||||
|
args
|
||||||
|
});
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static ANALYZER: OnceCell<AhoCorasick> = const { OnceCell::new() };
|
static ANALYZER: OnceCell<AhoCorasick> = const { OnceCell::new() };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user