Draw ui
This commit is contained in:
48
custom_consumption/src/app_config.rs
Normal file
48
custom_consumption/src/app_config.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use clap::Parser;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Solar system central backend
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct AppConfig {
|
||||
/// The path to the file to write to update the value
|
||||
#[clap(short, long, default_value = "/dev/shm/consumption.txt")]
|
||||
file_path: String,
|
||||
|
||||
/// Minimal value
|
||||
#[clap( long, default_value_t = -5000)]
|
||||
pub min: i64,
|
||||
|
||||
/// Maximal value
|
||||
#[clap(long, default_value_t = 5000)]
|
||||
pub max: i64,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref ARGS: AppConfig = {
|
||||
AppConfig::parse()
|
||||
};
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
/// Get parsed command line arguments
|
||||
pub fn get() -> &'static AppConfig {
|
||||
&ARGS
|
||||
}
|
||||
|
||||
/// Path to the file to update the value
|
||||
pub fn file_path(&self) -> PathBuf {
|
||||
Path::new(&self.file_path).to_path_buf()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::app_config::AppConfig;
|
||||
|
||||
#[test]
|
||||
fn verify_cli() {
|
||||
use clap::CommandFactory;
|
||||
AppConfig::command().debug_assert()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user