1use std::sync::Arc;
2
3use args::{Args, CARGO_PKG_NAME};
4use clap::Parser;
5use parser_config::ParserConfig;
6
7pub mod args;
8mod colors;
9mod meta;
10pub mod parser_config;
11pub mod state;
12
13pub struct Config {
14 pub args: Args,
15 pub parser: Arc<ParserConfig>,
16}
17
18impl Config {
19 pub fn new(parser_config_location: &str) -> Self {
20 let parser_config: Arc<ParserConfig> = if let Ok(config) =
21 confy::load::<ParserConfig>(CARGO_PKG_NAME, parser_config_location)
22 && config.metadata.mod_installer_version == env!("CARGO_PKG_VERSION")
23 {
24 Arc::new(config)
25 } else {
26 Arc::new(ParserConfig::default())
27 };
28 Self {
29 args: Args::parse(),
30 parser: parser_config,
31 }
32 }
33}