summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2019-03-01 20:28:25 +0100
committerCanop <cano.petrole@gmail.com>2019-03-01 20:28:25 +0100
commitcf19b2f4842d06cf4dea6ab56d8d6a871a04d938 (patch)
tree677d4243e21bd5df0848f289017f3d82cb8dd94c /src/main.rs
parent00fd417fd51ccf767650b3495f4435db2a6558e2 (diff)
Pattern based verb arguments
Here are some examples of verbs which can be configured now. [[verbs]] invocation = "mkdir {subpath}" execution = "/bin/mkdir -p {directory}/{subpath}" As before, when only one verb possibly matches, you don't have to type its complete name. You can do mk new folder (and yes, space are ok) [[verbs]] invocation = "create {subpath}" execution = "/usr/bin/nvim {directory}/{subpath}" [[verbs]] invocation = "rm" execution = "/bin/rm -rf {file}" confirm = true leave_broot = false [[verbs]] invocation = "mv {subpath}" execution = "/bin/mv {file} {parent}/{subpath}" Here's a more complex one, creating a directory then a file in neovim, by destructuring the argument in name and suffix: [[verbs]] invocation = "blop {name}\\.{type}" execution = "/bin/mkdir {parent}/{type} && /usr/bin/nvim {parent}/{type}/{name}.{type}" from_shell = true Notice the `\\.` ? That's because the invocation pattern is interpreted as a regular expression (with just a shortcut for the easy case, enablinrg `{name}`). The whole regular expression syntax may be useful for more complex rules. Let's say we don't want the type to contain dots, then we do this: [[verbs]] invocation = "blop {name}\\.(?P<type>[^.]+)" execution = "/bin/mkdir {parent}/{type} && /usr/bin/nvim {parent}/{type}/{name}.{type}" from_shell = true
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 7cb2cdc..08d6ccb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,6 +38,8 @@ mod tree_build;
mod tree_options;
mod tree_views;
mod verbs;
+mod verb_invocation;
+mod verb_store;
use log::LevelFilter;
use simplelog;
@@ -51,7 +53,7 @@ use crate::app_context::AppContext;
use crate::conf::Conf;
use crate::errors::ProgramError;
use crate::external::Launchable;
-use crate::verbs::VerbStore;
+use crate::verb_store::VerbStore;
// There's no log unless the BROOT_LOG environment variable is set to
// a valid log level (trace, debug, info, warn, error, off)