summaryrefslogtreecommitdiffstats
path: root/src/commands.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2019-01-21 21:19:43 +0100
committerCanop <cano.petrole@gmail.com>2019-01-21 21:19:43 +0100
commit3e5faa68e74e8c206e91d06d03447c16e2c20b74 (patch)
tree4715dd80e15351f390cbfa7eb93bf089937f6530 /src/commands.rs
parent8aa96fb62ef7622b2db8473c10fe7bb99c3c163c (diff)
--cmd program argument to pass a sequence of commands
Right not I use it for tests & benchmarks
Diffstat (limited to 'src/commands.rs')
-rw-r--r--src/commands.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/commands.rs b/src/commands.rs
index 38167c9..935de53 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -101,6 +101,24 @@ impl Command {
}
c
}
+ // build a command from a string
+ // Note that this isn't used (or usable) for interpretation
+ // of the in-app user input. It's meant for interpretation
+ // of a file or from a sequence of commands passed as argument
+ // of the program.
+ // A ':', even if at the end, is assumed to mean that the
+ // command must be executed (it's equivalent to the user
+ // typing `enter` in the app
+ // This specific syntax isn't definitive
+ pub fn from(raw: String) -> Command {
+ let parts = CommandParts::from(&raw);
+ let action = Action::from(&parts, raw.contains(":"));
+ Command {
+ raw,
+ parts,
+ action,
+ }
+ }
pub fn add_key(&mut self, key: Key) {
match key {
Key::Char('\t') => {