summaryrefslogtreecommitdiffstats
path: root/src/poem/recite.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/poem/recite.rs')
-rw-r--r--src/poem/recite.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/poem/recite.rs b/src/poem/recite.rs
index f2af591..e37b7c6 100644
--- a/src/poem/recite.rs
+++ b/src/poem/recite.rs
@@ -1,5 +1,6 @@
mod ps;
use super::Poem;
+use crate::compose::Environment;
use crate::path;
use crate::poem::anthology;
use crate::poem::elements::rune::Rune;
@@ -10,11 +11,11 @@ use std::{
};
pub trait Reciteable {
- fn recite(&self, bins: &mut Vec<String>, stdout: Option<bool>) -> Result<String, io::Error>;
+ fn recite(&self, env: &mut Environment, stdout: Option<bool>) -> Result<String, io::Error>;
}
impl Reciteable for Poem {
- fn recite(&self, bins: &mut Vec<String>, stdout: Option<bool>) -> Result<String, io::Error> {
+ fn recite(&self, env: &mut Environment, stdout: Option<bool>) -> Result<String, io::Error> {
// Should we print to stdout or always capture it
let stdout = stdout.unwrap_or(true);
@@ -84,7 +85,7 @@ impl Reciteable for Poem {
Some(poem) => poem,
None => break, // TODO: Return an error
};
- let out = poem.recite(bins, Some(false))?;
+ let out = poem.recite(env, Some(false))?;
if out.contains("\n") {
let mut out = out.split("\n");
let next = out.next().unwrap_or("").trim();
@@ -121,16 +122,16 @@ impl Reciteable for Poem {
// Incant the verse if it's a built-in
let index = anthology::lookup(&verse.verb());
let status = if index.is_some() {
- anthology::incant(&verse, index.unwrap(), bins)
+ anthology::incant(&verse, index.unwrap(), env)
} else {
// Incant the verse, based on its meter
// Check if the verb exists
// If it doesn't exist, try refreshing the binary cache, and check
// again
// If it still doesn't exist, print an error
- if !verse.spellcheck(bins) {
- *bins = path::refresh();
- if !verse.spellcheck(bins) {
+ if !verse.spellcheck(&env.bins) {
+ env.bins = path::refresh();
+ if !verse.spellcheck(&env.bins) {
eprintln!("dwvsh: {}: command not found", verse.verb());
if verse.meter != Rune::And {