diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-02-07 00:28:26 -0500 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-02-07 00:28:26 -0500 |
commit | 238e0c88e02d2596fad8ca5524877b1010b9a33b (patch) | |
tree | eddd783ef1cbef5f39cb4ed624d0f8763a6fd4be | |
parent | 48107ac5263d035fe48b67df8cfdd833dae92804 (diff) |
Update documentation again, also change temp a bit
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | src/constants.rs | 7 | ||||
-rw-r--r-- | src/main.rs | 18 |
3 files changed, 23 insertions, 13 deletions
@@ -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 = <kelvin|k|celsius|c|fahrenheit|f>`. + - 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 { |