From caafa8f7155689f6f73e1a96e38d0ec5a0554eb3 Mon Sep 17 00:00:00 2001 From: hr567 Date: Mon, 3 Jun 2024 16:49:25 +0800 Subject: [PATCH] Implement keywords_file option Signed-off-by: hr567 --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a35bc84..3c904bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,14 @@ struct Args { keywords: Vec, } -static ARGS: Lazy = Lazy::new(Args::parse); +static ARGS: Lazy = 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! { static ANALYZER: OnceCell = const { OnceCell::new() }; }