summaryrefslogtreecommitdiffstats
path: root/src/conf.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-02-04 22:25:19 +0100
committerCanop <cano.petrole@gmail.com>2020-02-04 22:25:19 +0100
commitaff659b73a54532ea3dd195d4edc33fc8056f5dd (patch)
tree8c5049e470f9d9c6adf6d5c66ba70f3c9dfddcdf /src/conf.rs
parent5e43b91284b6ad1c30ec764de7885c55e6dd6ef5 (diff)
default_args in conf.toml and new launch flags
New flags are mostly here to let you negate on command line the flags you've set in conf.toml. For example `-D` negates `-d`.
Diffstat (limited to 'src/conf.rs')
-rw-r--r--src/conf.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/conf.rs b/src/conf.rs
index 77f0590..276304f 100644
--- a/src/conf.rs
+++ b/src/conf.rs
@@ -22,6 +22,7 @@ use {
#[derive(Default)]
pub struct Conf {
+ pub default_flags: String, // the flags to apply before cli ones
pub verbs: Vec<VerbConf>,
pub skin: HashMap<String, CompoundStyle>,
}
@@ -100,6 +101,10 @@ impl Conf {
pub fn read_file(&mut self, filepath: &Path) -> Result<(), ConfError> {
let data = fs::read_to_string(filepath)?;
let root: Value = data.parse::<Value>()?;
+ // reading default flags
+ if let Some(s) = string_field(&root, "default_flags") {
+ self.default_flags.push_str(&s);
+ }
// reading verbs
if let Some(Value::Array(verbs_value)) = &root.get("verbs") {
for verb_value in verbs_value.iter() {
@@ -165,15 +170,22 @@ impl Conf {
}
const DEFAULT_CONF_FILE: &str = r#"
-# This configuration file lets you define new commands
-# or change the shortcut or triggering keys of built-in verbs.
-# You can change the colors of broot too.
-#
-# Configuration documentation is available at https://dystroy.org/broot
+###############################################################
+# This configuration file lets you
+# - define new commands
+# - change the shortcut or triggering keys of built-in verbs
+# - change the colors
+# - set default values for flags
#
+# Configuration documentation is available at
+# https://dystroy.org/broot
+###############################################################
+
+###############################################################
+# default flags
-#####################
-# user defined verbs:
+###############################################################
+# verbs and shortcuts
# If $EDITOR isn't set on your computer, you should either set it using
# something similar to
@@ -211,7 +223,7 @@ name = "view"
invocation = "view"
execution = "$PAGER {file}"
-#####################
+###############################################################
# Skin
# If you want to change the colors of broot,