Fix issue with default file paths not being respected; updated default file paths.
This commit is contained in:
parent
e7352ddef1
commit
0697d9dd56
12
.travis.yml
12
.travis.yml
|
@ -51,18 +51,18 @@ before_deploy:
|
|||
cargo build --release --target $TARGET;
|
||||
cp ./target/x86_64-pc-windows-msvc/release/btm btm;
|
||||
strip btm;
|
||||
cp default_config.toml btm.toml;
|
||||
tar -czvf bottom_x86_64-pc-windows-msvc.tar.gz btm btm.toml;
|
||||
cp default_config.toml bottom.toml;
|
||||
tar -czvf bottom_x86_64-pc-windows-msvc.tar.gz btm bottom.toml;
|
||||
else
|
||||
cargo build --release;
|
||||
cp ./target/release/btm btm;
|
||||
strip btm;
|
||||
cp default_config.toml btm.toml;
|
||||
cp default_config.toml bottom.toml;
|
||||
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
|
||||
tar -czvf bottom_x86_64-unknown-linux-gnu.tar.gz btm btm.toml;
|
||||
tar -czvf bottom_source_code.tar.gz ./src ./Cargo.toml LICENSE tests sample_config.toml btm.toml;
|
||||
tar -czvf bottom_x86_64-unknown-linux-gnu.tar.gz btm bottom.toml;
|
||||
tar -czvf bottom_source_code.tar.gz ./src ./Cargo.toml LICENSE tests sample_config.toml bottom.toml;
|
||||
elif [[ $TRAVIS_OS_NAME == "osx" ]]; then
|
||||
tar -czvf bottom_x86_64-apple-darwin.tar.gz btm btm.toml;
|
||||
tar -czvf bottom_x86_64-apple-darwin.tar.gz btm bottom.toml;
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ lto = true
|
|||
[dependencies]
|
||||
chrono = "0.4.10"
|
||||
clap = "2.33.0"
|
||||
dirs = "2.0.2"
|
||||
fern = "0.5.9"
|
||||
futures-timer = "3.0.2"
|
||||
futures = "0.3.4"
|
||||
|
|
|
@ -107,7 +107,7 @@ Run using `btm`.
|
|||
|
||||
- `-s`, `--show_disabled_data` will show data entries in the graph legends even if the lines for that entry are disabled.
|
||||
|
||||
- `-C`, `--config` takes in a file path leading to a TOML file.
|
||||
- `-C`, `--config` takes in a file path leading to a TOML file. By default it checks `~/.config/btm/btm.toml` or `./btm.toml` for Unix and Windows respectively.
|
||||
|
||||
### Keybindings
|
||||
|
||||
|
@ -191,6 +191,7 @@ Note that `q` is disabled while in the search widget.
|
|||
- [chrono](https://github.com/chronotope/chrono)
|
||||
- [clap](https://github.com/clap-rs/clap)
|
||||
- [crossterm](https://github.com/TimonPost/crossterm)
|
||||
- [dirs](https://github.com/soc/dirs-rs)
|
||||
- [fern](https://github.com/daboross/fern)
|
||||
- [futures-rs](https://github.com/rust-lang-nursery/futures-rs)
|
||||
- [futures-timer](https://github.com/rustasync/futures-timer)
|
||||
|
|
|
@ -34,5 +34,5 @@ Note some colours may not be compatible with the terminal you are using. For exa
|
|||
|
||||
bottom will check specific locations by default for a config file.
|
||||
|
||||
- For Unix-based systems: `~/.config/btm/btm.toml`.
|
||||
- For Windows: `./btm.toml`.
|
||||
- For Unix-based systems: `$HOME/.config/bottom/bottom.toml`.
|
||||
- For Windows: `{FOLDERID_RoamingAppData}\bottom\bottom.toml` (for example, `C:\Users\Clement\AppData\Roaming\bottom\bottom.toml`).
|
||||
|
|
|
@ -6,8 +6,8 @@ pub const MAX_KEY_TIMEOUT_IN_MILLISECONDS: u128 = 1000;
|
|||
pub const NUM_COLOURS: i32 = 256;
|
||||
|
||||
// Config and flags
|
||||
pub const DEFAULT_UNIX_CONFIG_FILE_PATH: &str = "~/.config/btm/btm.toml";
|
||||
pub const DEFAULT_WINDOWS_CONFIG_FILE_PATH: &str = "./btm.toml";
|
||||
pub const DEFAULT_UNIX_CONFIG_FILE_PATH: &str = ".config/bottom/bottom.toml";
|
||||
pub const DEFAULT_WINDOWS_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";
|
||||
|
||||
// Help text
|
||||
pub const GENERAL_HELP_TEXT: [&str; 15] = [
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -213,7 +213,6 @@ fn main() -> error::Result<()> {
|
|||
|
||||
let mut first_run = true;
|
||||
loop {
|
||||
// TODO: [OPT] this should not block...
|
||||
if let Ok(recv) = rx.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
||||
match recv {
|
||||
Event::KeyInput(event) => {
|
||||
|
@ -408,15 +407,28 @@ fn create_logger() -> error::Result<()> {
|
|||
}
|
||||
|
||||
fn create_config(flag_config_location: Option<&str>) -> error::Result<Config> {
|
||||
let config_path = std::path::Path::new(flag_config_location.unwrap_or(
|
||||
if cfg!(target_os = "windows") {
|
||||
DEFAULT_WINDOWS_CONFIG_FILE_PATH
|
||||
use std::ffi::OsString;
|
||||
let config_path = if let Some(conf_loc) = flag_config_location {
|
||||
OsString::from(conf_loc)
|
||||
} else if cfg!(target_os = "windows") {
|
||||
if let Some(home_path) = dirs::config_dir() {
|
||||
let mut path = home_path;
|
||||
path.push(DEFAULT_WINDOWS_CONFIG_FILE_PATH);
|
||||
path.into_os_string()
|
||||
} else {
|
||||
DEFAULT_UNIX_CONFIG_FILE_PATH
|
||||
},
|
||||
));
|
||||
OsString::new()
|
||||
}
|
||||
} else if let Some(home_path) = dirs::home_dir() {
|
||||
let mut path = home_path;
|
||||
path.push(DEFAULT_UNIX_CONFIG_FILE_PATH);
|
||||
path.into_os_string()
|
||||
} else {
|
||||
OsString::new()
|
||||
};
|
||||
|
||||
if let Ok(config_str) = std::fs::read_to_string(config_path) {
|
||||
let path = std::path::Path::new(&config_path);
|
||||
|
||||
if let Ok(config_str) = std::fs::read_to_string(path) {
|
||||
Ok(toml::from_str(config_str.as_str())?)
|
||||
} else {
|
||||
Ok(Config::default())
|
||||
|
|
|
@ -4,6 +4,8 @@ use std::process::Command;
|
|||
|
||||
// These tests are mostly here just to ensure that invalid results will be caught when passing arguments...
|
||||
|
||||
// TODO: [TEST] Allow for release testing.
|
||||
|
||||
//======================RATES======================//
|
||||
|
||||
fn get_os_binary_loc() -> String {
|
||||
|
@ -36,7 +38,9 @@ fn test_large_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.arg("18446744073709551616")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains("rate to be less than unsigned INT_MAX."));
|
||||
.stderr(predicate::str::contains(
|
||||
"rate to be less than unsigned INT_MAX.",
|
||||
));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -48,7 +52,9 @@ fn test_negative_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.arg("-1000")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains("wasn't expected, or isn't valid in this context"));
|
||||
.stderr(predicate::str::contains(
|
||||
"wasn't expected, or isn't valid in this context",
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue