use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct GlobalConfig {
pub rule_cache_path: PathBuf,
pub gh_proxy_url: String,
pub http_timeout: u64,
pub verbose: bool,
}
impl Default for GlobalConfig {
fn default() -> Self {
Self {
rule_cache_path: PathBuf::from("wappalyzer_rules.mp"),
gh_proxy_url: "https://ghfast.top/".to_string(),
http_timeout: 30,
verbose: false,
}
}
}
pub struct ConfigManager;
impl ConfigManager {
pub fn get_default() -> GlobalConfig {
GlobalConfig::default()
}
pub fn custom() -> CustomConfigBuilder {
CustomConfigBuilder::new()
}
}
#[derive(Debug, Clone)]
pub struct CustomConfigBuilder {
config: GlobalConfig,
}
impl CustomConfigBuilder {
pub fn new() -> Self {
Self {
config: GlobalConfig::default(),
}
}
pub fn rule_cache_path(mut self, path: PathBuf) -> Self {
self.config.rule_cache_path = path;
self
}
pub fn gh_proxy_url(mut self, url: String) -> Self {
self.config.gh_proxy_url = url;
self
}
pub fn http_timeout(mut self, timeout: u64) -> Self {
self.config.http_timeout = timeout;
self
}
pub fn verbose(mut self, verbose: bool) -> Self {
self.config.verbose = verbose;
self
}
pub fn build(self) -> GlobalConfig {
self.config
}
}