diff --git a/README.md b/README.md index e710035b..da0c2cf5 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,16 @@ Run using `btm`. - `-R`, `--regex` will default to using regex. -- `-C`, `--config` takes in a file path leading to a TOML file, where one can set flags by default. The default path this will check is, on Linux, `~/.config/btm/btm.toml`. Options are the same as the long names as other flags (ie: `regex = true`). See the [sample config](./sample_config.toml) for an example. +- `-C`, `--config` takes in a file path leading to a TOML file, where one can set flags to execute by default. + + - Options are generally the same as the long names as other flags (ie: `case_sensitive = true`). + - For temperature type, use `temperature_type = `. + - See the [sample config](./sample_config.toml) for an example. + + bottom will check specific locations by default for a config file. + + - For Unix-based systems: `~/.config/btm/btm.toml`. + - For Windows: TBD. ### Keybindings diff --git a/src/constants.rs b/src/constants.rs index cc7d690c..19b9d1d6 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -6,8 +6,7 @@ pub const MAX_KEY_TIMEOUT_IN_MILLISECONDS: u128 = 1000; pub const NUM_COLOURS: i32 = 256; // Config and flags -pub const DEFAULT_CONFIG_FILE_PATH: &str = "~/.config/btm/btm.toml"; +pub const DEFAULT_UNIX_CONFIG_FILE_PATH: &str = "~/.config/btm/btm.toml"; -pub const KELVIN: &str = "kelvin"; -pub const FAHRENHEIT: &str = "fahrenheit"; -pub const CELSIUS: &str = "celsius"; +// TODO: [CONF] Default windows path? +pub const DEFAULT_WINDOWS_CONFIG_FILE_PATH: &str = ""; diff --git a/src/main.rs b/src/main.rs index fdf81072..3920b7c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,11 +99,13 @@ fn main() -> error::Result<()> { utils::logging::init_logger()?; } - let config_path = std::path::Path::new( - matches - .value_of("CONFIG_LOCATION") - .unwrap_or(DEFAULT_CONFIG_FILE_PATH), - ); + let config_path = std::path::Path::new(matches.value_of("CONFIG_LOCATION").unwrap_or( + if cfg!(target_os = "windows") { + DEFAULT_WINDOWS_CONFIG_FILE_PATH + } else { + DEFAULT_UNIX_CONFIG_FILE_PATH + }, + )); let config_string = std::fs::read_to_string(config_path); let config_toml: Config = if let Ok(config_str) = config_string { @@ -143,9 +145,9 @@ fn main() -> error::Result<()> { } else if let Some(temp_type) = config_toml.temperature_type { // Give lowest priority to config. match temp_type.as_str() { - constants::FAHRENHEIT => data_harvester::temperature::TemperatureType::Fahrenheit, - constants::KELVIN => data_harvester::temperature::TemperatureType::Kelvin, - constants::CELSIUS => data_harvester::temperature::TemperatureType::Celsius, + "fahrenheit" | "f" => data_harvester::temperature::TemperatureType::Fahrenheit, + "kelvin" | "k" => data_harvester::temperature::TemperatureType::Kelvin, + "celsius" | "c" => data_harvester::temperature::TemperatureType::Celsius, _ => data_harvester::temperature::TemperatureType::Celsius, } } else {