Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# configuration
nvrs relies on a TOML configuration file ([example](https://github.com/adamperkowski/nvrs/blob/main/nvrs.toml)) containing basic settings, such as `oldver`, `newver` & `keyfile` paths, as well as [package entries](/package-entries.md). supported config paths:
- `$XDG_CONFIG_HOME/nvrs.toml` (`~/.config/nvrs.toml` if the variable is not set)
- `./nvrs.toml`
- `$NVRS_CONFIG_DIR/nvrs.toml`
- `$XDG_CONFIG_HOME/nvrs/nvrs.toml` (`$HOME/.config/nvrs/nvrs.toml` if the variable is not set)
- `$HOME/.config/nvrs.toml`
- custom paths set with `nvrs --config`
10 changes: 8 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,15 @@ pub async fn load(custom_path: &Option<String>) -> error::Result<(Config, PathBu
}
} else {
let default_path = Path::new("nvrs.toml");
let config_env_nvrs = match env::var("NVRS_CONFIG_DIR") {
Ok(s) => Ok(expand_tilde(s)?),
Err(e) => Err(e),
};
let config_home = format!(
"{}/nvrs/nvrs.toml",
env::var("XDG_CONFIG_HOME").unwrap_or(expand_tilde("~/.config".to_string())?)
"{}/nvrs.toml",
config_env_nvrs
.or_else(|_| env::var("XDG_CONFIG_HOME").map(|v| format!("{}/nvrs", v)))
.unwrap_or(expand_tilde("~/.config/nvrs".to_string())?)
);
let config_home_non_xdg = expand_tilde("~/.config/nvrs.toml".to_string())?;
let config_home_non_xdg = Path::new(&config_home_non_xdg);
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use colored::Colorize;
const RATE_LIMIT: &str = "we might be getting rate-limited here";
const CONFIG_PATHS: &str = "config file locations:
./nvrs.toml
$NVRS_CONFIG_DIR/nvrs.toml
$XDG_CONFIG_HOME/nvrs/nvrs.toml
$HOME/.config/nvrs.toml";
const NOT_EMPTY: &str = "make sure the file is not empty";
Expand Down