Add default value for analysis dir
Signed-off-by: hr567 <hr567@hr567.me>
This commit is contained in:
parent
caafa8f715
commit
72574323ba
@ -6,7 +6,7 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.4", features = ["derive"] }
|
clap = { version = "4.5.4", features = ["derive", "string"] }
|
||||||
dashmap = { version = "5.5.3", features = ["serde"] }
|
dashmap = { version = "5.5.3", features = ["serde"] }
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
indicatif = "0.17.8"
|
indicatif = "0.17.8"
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -1,5 +1,6 @@
|
|||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::{BTreeMap, HashMap, VecDeque};
|
use std::collections::{BTreeMap, HashMap, VecDeque};
|
||||||
|
use std::env::current_dir;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@ -20,20 +21,23 @@ use tracing::Instrument;
|
|||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[arg(short, long)]
|
#[arg(short, long, default_value =
|
||||||
|
current_dir().unwrap().into_os_string())]
|
||||||
directory: PathBuf,
|
directory: PathBuf,
|
||||||
#[arg(short, long, default_value = "16")]
|
#[arg(short, long, default_value = "16")]
|
||||||
jobs: usize,
|
jobs: usize,
|
||||||
#[arg(short = 'f', long)]
|
#[arg(short = 'f', long, default_value =
|
||||||
keywords_file: Option<PathBuf>,
|
current_dir().unwrap().join("keywords.txt").into_os_string())]
|
||||||
|
keywords_file: PathBuf,
|
||||||
#[arg(last = true)]
|
#[arg(last = true)]
|
||||||
keywords: Vec<String>,
|
keywords: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ARGS: Lazy<Args> = Lazy::new(|| {
|
static ARGS: Lazy<Args> = Lazy::new(|| {
|
||||||
let mut args = Args::parse();
|
let mut args = Args::parse();
|
||||||
if let Some(keywords_file) = args.keywords_file.take() {
|
if args.keywords_file.exists() {
|
||||||
let content = std::fs::read_to_string(keywords_file).expect("failed to read keywords file");
|
let content =
|
||||||
|
std::fs::read_to_string(&args.keywords_file).expect("failed to read keywords file");
|
||||||
args.keywords.extend(content.lines().map(|s| s.to_string()));
|
args.keywords.extend(content.lines().map(|s| s.to_string()));
|
||||||
}
|
}
|
||||||
args
|
args
|
||||||
|
Loading…
Reference in New Issue
Block a user