Update documentation again, also change temp a bit

This commit is contained in:
ClementTsang 2020-02-07 00:28:26 -05:00
parent 48107ac526
commit 238e0c88e0
3 changed files with 23 additions and 13 deletions

View file

@ -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

View file

@ -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 = "";

View file

@ -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 {