From b7c8866edc8960cc04ccde1aad95f3f7fd34c996 Mon Sep 17 00:00:00 2001 From: freyja Date: Thu, 3 Jun 2021 12:44:53 -0700 Subject: [PATCH] ;fray command --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/mod.rs | 6 ++++-- src/main.rs | 2 +- src/plane/parse.rs | 1 + src/plane/plane_commands.rs | 10 ++++++++++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 837e39f..27ce11e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "merlin" -version = "1.0.1" +version = "1.0.2" dependencies = [ "clap", "shellexpand", diff --git a/Cargo.toml b/Cargo.toml index 32ef3e2..1854e94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "merlin" -version = "1.0.1" +version = "1.0.2" authors = ["geremachek "] edition = "2018" diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 5fc9067..14ace15 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -48,6 +48,7 @@ pub enum Command { Decay, Destroy, Tether, + Fray, Mirror, Atom, Scribe, @@ -93,6 +94,7 @@ impl FromStr for Command { "decay" => Ok(Command::Decay), "destroy" => Ok(Command::Destroy), "tether" => Ok(Command::Tether), + "fray" => Ok(Command::Fray), "mirror" => Ok(Command::Mirror), "atom" => Ok(Command::Atom), "scribe" => Ok(Command::Scribe), @@ -117,7 +119,7 @@ impl Command { Command::Volumes | Command::Carved => true, Command::Focus | Command::Traverse | Command::Appear | Command::Shave | Command::Shelve | Command::Incant | Command::Inscribe | Command::Trample | Command::Peek | Command::Summon | Command::Dub | Command::Spellbook | Command::Shift | Command::Infix | Command::Spine | Command::Nomen => args >= 1, - Command::Infuse | Command::Tether | Command::Peer => args >= 2, + Command::Infuse | Command::Tether | Command::Fray | Command::Peer => args >= 2, } } @@ -140,7 +142,7 @@ impl Command { Command::Volumes | Command::Carved => return Ok(0), Command::Focus | Command::Traverse | Command::Appear | Command::Shave | Command::Shelve | Command::Inscribe | Command::Trample | Command::Incant | Command::Summon | Command::Dub | Command::Spellbook | Command::Shift | Command::Infix | Command::Peek | Command::Spine => return Ok(1), - Command::Infuse | Command::Peer => return Ok(2), + Command::Infuse | Command::Peer | Command::Fray => return Ok(2), Command::Genesis => return Ok(choose_mm(1, 0)) } } diff --git a/src/main.rs b/src/main.rs index 513d8ad..bcb4b0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ mod nomen; fn main() { let merlin_args = App::new("merlin:") .about("An esoteric, programmable text editor") - .version("1.0.1") + .version("1.0.2") .arg(Arg::with_name("no-errors") .short("n") .long("no-errors") diff --git a/src/plane/parse.rs b/src/plane/parse.rs index d374880..39e3522 100644 --- a/src/plane/parse.rs +++ b/src/plane/parse.rs @@ -116,6 +116,7 @@ impl Plane { Command::Decay => self.stack.decay(), Command::Destroy => self.stack.destroy(), Command::Tether => return oksome(commands::tether(&data[..data.len()-1], &data.last().unwrap())), + Command::Fray => self.fray(&data[data.len()-2], &data.last().unwrap()), Command::Atom => self.vision = Vision::Atom, Command::Scribe => self.vision = Vision::Scribe, Command::Mirror => self.print_result = !self.print_result, diff --git a/src/plane/plane_commands.rs b/src/plane/plane_commands.rs index 953d70b..79bba88 100644 --- a/src/plane/plane_commands.rs +++ b/src/plane/plane_commands.rs @@ -97,4 +97,14 @@ impl Plane { self.current_volume + 1 } } + + // split atom by another atom + + pub fn fray(&mut self, atom: &str, s: &str) { + for a in atom.split(s) { + if !a.is_empty() { + self.stack.push(a.to_string()) + } + } + } }