mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-21 18:40:19 +00:00
expand tilde in config file (#102)
This commit is contained in:
parent
a6b30b746c
commit
97054d3133
4 changed files with 59 additions and 4 deletions
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
- Config option `signature-delimiter` to customize the signature delimiter (default to `-- \n`) [[#114](https://github.com/soywod/himalaya/pull/114)]
|
||||
- Expand tilde and env vars for `downloads-dir` and `signature` [#102]
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -285,6 +286,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#95]: https://github.com/soywod/himalaya/issues/95
|
||||
[#96]: https://github.com/soywod/himalaya/issues/96
|
||||
[#100]: https://github.com/soywod/himalaya/issues/100
|
||||
[#102]: https://github.com/soywod/himalaya/issues/102
|
||||
[#109]: https://github.com/soywod/himalaya/issues/109
|
||||
[#117]: https://github.com/soywod/himalaya/issues/117
|
||||
[#121]: https://github.com/soywod/himalaya/issues/121
|
||||
|
|
41
Cargo.lock
generated
41
Cargo.lock
generated
|
@ -195,6 +195,27 @@ version = "0.8.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
|
||||
|
||||
[[package]]
|
||||
name = "dirs-next"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"dirs-sys-next",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys-next"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.26"
|
||||
|
@ -328,6 +349,7 @@ dependencies = [
|
|||
"rfc2047-decoder",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shellexpand",
|
||||
"terminal_size",
|
||||
"toml",
|
||||
"tree_magic",
|
||||
|
@ -809,6 +831,16 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall 0.2.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
|
@ -937,6 +969,15 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shellexpand"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829"
|
||||
dependencies = [
|
||||
"dirs-next",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
|
|
|
@ -19,6 +19,7 @@ native-tls = "0.2"
|
|||
rfc2047-decoder = "0.1.2"
|
||||
serde = {version = "1.0.118", features = ["derive"]}
|
||||
serde_json = "1.0.61"
|
||||
shellexpand = "2.1.0"
|
||||
terminal_size = "0.1.15"
|
||||
toml = "0.5.8"
|
||||
tree_magic = "0.2.3"
|
||||
|
|
|
@ -2,6 +2,7 @@ use error_chain::error_chain;
|
|||
use lettre::transport::smtp::authentication::Credentials as SmtpCredentials;
|
||||
use log::debug;
|
||||
use serde::Deserialize;
|
||||
use shellexpand;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
|
@ -230,8 +231,17 @@ impl Config {
|
|||
account
|
||||
.downloads_dir
|
||||
.as_ref()
|
||||
.unwrap_or(self.downloads_dir.as_ref().unwrap_or(&env::temp_dir()))
|
||||
.to_owned()
|
||||
.and_then(|dir| dir.to_str())
|
||||
.and_then(|dir| shellexpand::full(dir).ok())
|
||||
.map(|dir| PathBuf::from(dir.to_string()))
|
||||
.unwrap_or(
|
||||
self.downloads_dir
|
||||
.as_ref()
|
||||
.and_then(|dir| dir.to_str())
|
||||
.and_then(|dir| shellexpand::full(dir).ok())
|
||||
.map(|dir| PathBuf::from(dir.to_string()))
|
||||
.unwrap_or(env::temp_dir()),
|
||||
)
|
||||
.join(filename)
|
||||
}
|
||||
|
||||
|
@ -264,8 +274,9 @@ impl Config {
|
|||
.signature
|
||||
.as_ref()
|
||||
.or_else(|| self.signature.as_ref());
|
||||
|
||||
sig.and_then(|sig| fs::read_to_string(sig).ok())
|
||||
sig.and_then(|sig| shellexpand::full(sig).ok())
|
||||
.map(|sig| sig.to_string())
|
||||
.and_then(|sig| fs::read_to_string(sig).ok())
|
||||
.or_else(|| sig.map(|sig| sig.to_owned()))
|
||||
.map(|sig| String::new() + sig_delim + sig.as_ref())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue