From 9b3e4dd71ec1491e3580e079e9be1b42117a74c9 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Thu, 4 Apr 2024 00:47:24 -0600 Subject: Add better support for aliases Make sure to interpret alias values as their own poems, since aliases can be fairly complex. --- src/poem/anthology/source.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/poem/anthology/source.rs') diff --git a/src/poem/anthology/source.rs b/src/poem/anthology/source.rs index ed4ed13..77d1330 100644 --- a/src/poem/anthology/source.rs +++ b/src/poem/anthology/source.rs @@ -12,7 +12,7 @@ use std::fs; /// ```sh /// source ~/.dwvshrc /// ``` -pub fn incant(verse: &Verse, env: &mut Environment) -> i32 { +pub fn incant(verse: &Verse, out: &mut String, env: &mut Environment) -> i32 { let files = match verse.clause() { Some(clause) => clause, None => { @@ -42,13 +42,15 @@ pub fn incant(verse: &Verse, env: &mut Environment) -> i32 { } }; - match poem.recite(env, None) { - Ok(_) => {} + let stdout = if verse.couplet { Some(true) } else { None }; + + *out = match poem.recite(env, stdout) { + Ok(out) => out, Err(e) => { eprintln!("dwvsh: {}", e.to_string().to_lowercase()); continue; } - } + }; } 0 -- cgit v1.2.3