mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-23 00:24:17 +02:00
Fix lints
This commit is contained in:
parent
e1b0c92843
commit
1979b6c5ec
2 changed files with 16 additions and 18 deletions
|
|
@ -759,7 +759,7 @@ impl ConfigLoader {
|
|||
/// Create a loader that uses the default config file location. If no file is present at the default location, the
|
||||
/// default configuration is used.
|
||||
pub fn read_default_path() -> Result<Self> {
|
||||
let path = get_default_config_path().context("Could not determine default config path.")?;
|
||||
let path = get_default_config_path();
|
||||
Self::read_internal(path, true)
|
||||
}
|
||||
|
||||
|
|
@ -777,24 +777,24 @@ impl ConfigLoader {
|
|||
///
|
||||
/// Note that this function does not verify whether the directory at that
|
||||
/// location exists, or is a directory.
|
||||
pub fn get_config_dir() -> Result<(PathBuf, PathSource)> {
|
||||
pub fn get_config_dir() -> (PathBuf, PathSource) {
|
||||
// Allow overriding the config directory by setting the
|
||||
// $TEALDEER_CONFIG_DIR env variable.
|
||||
if let Ok(value) = env::var("TEALDEER_CONFIG_DIR") {
|
||||
return Ok((PathBuf::from(value), PathSource::EnvVar));
|
||||
return (PathBuf::from(value), PathSource::EnvVar);
|
||||
}
|
||||
|
||||
Ok((SYSTEM_DIRECTORIES.config.clone(), PathSource::OsConvention))
|
||||
(SYSTEM_DIRECTORIES.config.clone(), PathSource::OsConvention)
|
||||
}
|
||||
|
||||
/// Return the path to the config file.
|
||||
///
|
||||
/// Note that this function does not verify whether the file at that location
|
||||
/// exists, or is a file.
|
||||
pub fn get_default_config_path() -> Result<PathWithSource> {
|
||||
let (mut path, source) = get_config_dir()?;
|
||||
pub fn get_default_config_path() -> PathWithSource {
|
||||
let (mut path, source) = get_config_dir();
|
||||
path.push(CONFIG_FILE_NAME);
|
||||
Ok(PathWithSource { path, source })
|
||||
PathWithSource { path, source }
|
||||
}
|
||||
|
||||
/// Create default config file.
|
||||
|
|
@ -804,7 +804,7 @@ pub fn make_default_config(path: Option<&Path>) -> Result<PathBuf> {
|
|||
let config_file_path = if let Some(p) = path {
|
||||
p.into()
|
||||
} else {
|
||||
let (config_dir, _) = get_config_dir()?;
|
||||
let (config_dir, _) = get_config_dir();
|
||||
|
||||
// Ensure that config directory exists
|
||||
if config_dir.exists() {
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -105,16 +105,14 @@ fn update_cache(
|
|||
|
||||
/// Show file paths
|
||||
fn show_paths(config: &Config) {
|
||||
let config_dir = get_config_dir().map_or_else(
|
||||
|e| format!("[Error: {e}]"),
|
||||
|(mut path, source)| {
|
||||
path.push(""); // Trailing path separator
|
||||
match path.to_str() {
|
||||
Some(path) => format!("{path} ({source})"),
|
||||
None => "[Invalid]".to_string(),
|
||||
}
|
||||
},
|
||||
);
|
||||
let config_dir = {
|
||||
let (mut path, source) = get_config_dir();
|
||||
path.push(""); // Trailing path separator
|
||||
match path.to_str() {
|
||||
Some(path) => format!("{path} ({source})"),
|
||||
None => "[Invalid]".to_string(),
|
||||
}
|
||||
};
|
||||
let config_path = config.file_path.to_string();
|
||||
let cache_dir = config.directories.cache_dir.to_string();
|
||||
let pages_dir = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue