summaryrefslogtreecommitdiffstats
path: root/src/conf.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-06-01 16:26:15 +0200
committerCanop <cano.petrole@gmail.com>2020-06-01 16:26:15 +0200
commit796cb6cb955b96dcfda5d2310169b82ab6ba6d65 (patch)
treeea7a6a3cc38f46040fb1a88ae0b7ceeb1e251ed0 /src/conf.rs
parent928365ae4bf4370b6bed57de1488d347fc5cc644 (diff)
`apply_to` verb property
Fix #237
Diffstat (limited to 'src/conf.rs')
-rw-r--r--src/conf.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/conf.rs b/src/conf.rs
index 80f6474..981a86e 100644
--- a/src/conf.rs
+++ b/src/conf.rs
@@ -5,6 +5,7 @@ use {
crate::{
errors::ConfError,
keys,
+ selection_type::SelectionType,
skin::SkinEntry,
tree::*,
verb::VerbConf,
@@ -147,6 +148,17 @@ impl Conf {
);
continue;
}
+ let selection_condition = match string_field(verb_value, "apply_to").as_deref() {
+ Some("file") => SelectionType::File,
+ Some("directory") => SelectionType::Directory,
+ Some("any") => SelectionType::Any,
+ None => SelectionType::Any,
+ Some(s) => {
+ eprintln!("Invalid [[verbs]] entry in configuration");
+ eprintln!("{:?} isn't a valid value of apply_to", s);
+ continue;
+ }
+ };
let verb_conf = VerbConf {
invocation,
execution,
@@ -155,6 +167,7 @@ impl Conf {
description: string_field(verb_value, "description"),
from_shell,
leave_broot,
+ selection_condition,
};
self.verbs.push(verb_conf);