iowo/crates/app/src/config.rs

25 lines
589 B
Rust
Raw Normal View History

2024-01-15 08:03:55 +00:00
use clap::Parser;
2024-01-12 08:36:30 +00:00
2024-01-15 08:03:55 +00:00
use self::{cli::Args, config_file::Configs};
2024-01-12 08:36:30 +00:00
2024-01-15 08:03:55 +00:00
mod cli;
mod config_file;
2024-01-12 08:36:30 +00:00
2024-01-15 08:03:55 +00:00
/// this struct may hold all configuration
pub struct Config {
pub startup_msg: bool,
2024-01-12 08:36:30 +00:00
}
2024-01-15 08:03:55 +00:00
impl Config {
pub fn read() -> Self {
let args = Args::parse();
let cfg = Configs::read(args.config_file);
2024-01-12 08:36:30 +00:00
2024-01-15 08:03:55 +00:00
Self {
// this is negated because to an outward api, the negative is more intuitive,
// while in the source the other way around is more intuitive
startup_msg: !(args.no_startup_message || cfg.no_startup_message),
2024-01-12 08:36:30 +00:00
}
}
}