diff options
Diffstat (limited to 'src/poem/recite.rs')
-rw-r--r-- | src/poem/recite.rs | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/src/poem/recite.rs b/src/poem/recite.rs index 60b7857..8b2fd1d 100644 --- a/src/poem/recite.rs +++ b/src/poem/recite.rs @@ -1,4 +1,3 @@ -mod ps; use super::Poem; use crate::compose::Environment; use crate::path; @@ -12,14 +11,11 @@ use std::{ }; pub trait Reciteable { - fn recite(&self, env: &mut Environment, stdout: Option<bool>) -> Result<Vec<u8>, io::Error>; + fn recite(&self, env: &mut Environment) -> Result<Vec<u8>, io::Error>; } impl Reciteable for Poem { - fn recite(&self, env: &mut Environment, stdout: Option<bool>) -> Result<Vec<u8>, io::Error> { - // Should we print to stdout or always capture it - let stdout = stdout.unwrap_or(true); - + fn recite(&self, env: &mut Environment) -> Result<Vec<u8>, io::Error> { // Variable for storing the output of a piped verse let mut out: Vec<u8> = Vec::new(); @@ -94,7 +90,7 @@ impl Reciteable for Poem { Some(poem) => poem, None => break, // TODO: Return an error }; - let mut out = poem.recite(env, Some(false))?; + let mut out = poem.recite(env)?; match out.last() { Some(last) => { if *last == b'\n' { @@ -165,29 +161,7 @@ impl Reciteable for Poem { continue; } - // Incant the verse, based on its meter - if stdout { - match verse.io { - Rune::Read => Rune::incant_read(&mut verse, &mut out, &mut pids)?, - Rune::Write => Rune::incant_write(&mut verse, &mut out, &mut pids)?, - Rune::Addendum => Rune::incant_addendum(&mut verse, &mut out, &mut pids)?, - _ => match verse.meter { - Rune::None => Rune::incant_none(&verse, &mut out)?, - Rune::Couplet => Rune::incant_couplet(&verse, &mut out)?, - Rune::Quiet => Rune::incant_quiet(&verse, &mut out, &mut pids)?, - Rune::And => Rune::incant_and(&verse, &mut out)?, - Rune::Continue => Rune::incant_continue(&verse, &mut out)?, - _ => unreachable!(), - }, - } - } else { - match verse.io { - Rune::Read => Rune::incant_read(&mut verse, &mut out, &mut pids)?, - Rune::Write => Rune::incant_write(&mut verse, &mut out, &mut pids)?, - Rune::Addendum => Rune::incant_addendum(&mut verse, &mut out, &mut pids)?, - _ => Rune::incant_couplet(&verse, &mut out)?, - } - } + verse.incant(&mut out, &mut pids)? }; // Break from the loop if the meter is not [Rune::Continue], and |