summaryrefslogtreecommitdiffstats
path: root/src/conf.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-05-01 14:01:02 +0200
committerCanop <cano.petrole@gmail.com>2020-05-01 21:31:53 +0200
commit0199162bc8d4fee5bb7f07fbb41570df95205057 (patch)
tree74c6bb798700b7dc7cc21c0173319f6ee51ba02c /src/conf.rs
parentcf52bbe7dc19cba78d65f431caa2af36c23da589 (diff)
command/verb/apply refactoring
* simpler, with immutable commands * more commands can be triggered by shortcuts * one can apply verbs to the input (using shortcuts)
Diffstat (limited to 'src/conf.rs')
-rw-r--r--src/conf.rs23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/conf.rs b/src/conf.rs
index 7349a29..99278fa 100644
--- a/src/conf.rs
+++ b/src/conf.rs
@@ -2,12 +2,7 @@
//! initializing if if it doesn't yet exist
use {
- crate::{
- errors::ConfError,
- keys,
- skin,
- verb::VerbConf,
- },
+ crate::{errors::ConfError, keys, skin, verb::VerbConf},
crossterm::style::Attribute,
directories::ProjectDirs,
std::{
@@ -48,8 +43,7 @@ fn bool_field(value: &Value, field_name: &str) -> Option<bool> {
/// return the instance of ProjectDirs holding broot's specific paths
pub fn app_dirs() -> ProjectDirs {
- ProjectDirs::from("org", "dystroy", "broot")
- .expect("Unable to find configuration directories")
+ ProjectDirs::from("org", "dystroy", "broot").expect("Unable to find configuration directories")
}
/// return the path to the config directory, based on XDG
@@ -58,9 +52,11 @@ pub fn dir() -> PathBuf {
}
impl Conf {
-
- pub fn default_location() -> PathBuf {
- dir().join("conf.toml")
+ pub fn default_location() -> &'static Path {
+ lazy_static! {
+ static ref CONF_PATH: PathBuf = dir().join("conf.toml");
+ }
+ &*CONF_PATH
}
/// read the configuration file from the default OS specific location.
@@ -108,8 +104,7 @@ impl Conf {
// reading verbs
if let Some(Value::Array(verbs_value)) = &root.get("verbs") {
for verb_value in verbs_value.iter() {
- let invocation = string_field(verb_value, "invocation")
- .unwrap_or("".to_string());
+ let invocation = string_field(verb_value, "invocation").unwrap_or("".to_string());
let key = string_field(verb_value, "key")
.map(|s| keys::parse_key(&s))
.transpose()?;
@@ -146,7 +141,6 @@ impl Conf {
from_shell,
leave_broot,
};
- debug!("\nread verb conf: {:?}\n", &verb_conf);
self.verbs.push(verb_conf);
}
@@ -320,4 +314,3 @@ execution = "$PAGER {file}"
# for example a skin suitable for white backgrounds
"#;
-