Skip to content

Commit

Permalink
add protean command, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
geremachek committed Nov 19, 2022
1 parent 99f80c2 commit 9b2b7ba
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "merlin"
version = "2.2.4"
version = "2.2.5"
authors = ["geremachek <[email protected]>"]
edition = "2021"

Expand Down
4 changes: 3 additions & 1 deletion src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub enum Command {
Dub,
Carve,
Spellbook,
Protean,
}

impl FromStr for Command {
Expand Down Expand Up @@ -107,6 +108,7 @@ impl FromStr for Command {
"dub" => Ok(Command::Dub),
"carve" => Ok(Command::Carve),
"spellbook" => Ok(Command::Spellbook),
"protean" => Ok(Command::Protean),
_ => Err(MerlinError::UnknownCommand),
}
}
Expand Down Expand Up @@ -138,7 +140,7 @@ impl Command {
Command::Nomen => all_with_min(1), // min of 1
Command::Spot | Command::Span | Command::Molecule | Command::Pen | Command::Orbit | Command::Pervert | Command::Decay | Command::Destroy |
Command::Atom | Command::Scribe | Command::Adieu | Command::Carve | Command::Pin | Command::Columns | Command::Burn | Command::Volume |
Command::Volumes | Command::Carved | Command::Atoms | Command::Tether | Command::Stitch | Command::Fray => 0,
Command::Volumes | Command::Carved | Command::Atoms | Command::Tether | Command::Stitch | Command::Fray | Command::Protean => 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::Spine | Command::Merlin | Command::Disenchant |
Command::Smash | Command::Decant | Command::Rune => 1,
Expand Down
3 changes: 2 additions & 1 deletion src/plane/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Plane {

fn push_volume(&mut self, v: Volume) {
if self.volumes.is_empty() || self.current_volume == self.volumes.len()-1 {
self.volumes.push_back(v);
self.volumes.push_back(v)
} else {
self.volumes.insert(self.current_volume+1, v);
}
Expand All @@ -87,6 +87,7 @@ impl Plane {
if self.volumes.len() > 1 {
self.current_volume += 1;
}

}

}
1 change: 1 addition & 0 deletions src/plane/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl Plane {
Command::Volume => return ok_some(self.volume().to_string()),
Command::Volumes => return ok_some(self.volumes.len().to_string()),
Command::Atoms => return ok_some(self.stack.len().to_string()),
Command::Protean => return ok_some(self.protean()),
_ => { // the following commands require buffers to be open
if self.volumes.len() > 0 { // buffers / files are open
let cvol = &mut self.volumes[self.current_volume]; // current volume
Expand Down
13 changes: 12 additions & 1 deletion src/plane/plane_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,16 @@ impl Plane {
.ok_or(MerlinError::UnknownNomen)?
.join(" "))
}
}

// return a list of all defined nomens to the stack

pub fn protean(&self) -> String {
let mut memory = String::new();

self.nomens
.keys()
.for_each(|nomen| { memory.push_str(nomen) ; memory.push_str("\n")});

return memory
}
}

0 comments on commit 9b2b7ba

Please sign in to comment.