summaryrefslogtreecommitdiffstats
path: root/src/compose
diff options
context:
space:
mode:
authorRory Dudley2024-06-04 16:25:32 -0600
committerRory Dudley2024-06-04 16:25:32 -0600
commitc4cd1e2c165c4f34ebf67fa9350f8732b2aeca13 (patch)
treea8dd06c7563c205eb4710f620cf89d89ae17d98b /src/compose
parentdedadcfd30516c40692fe495a6ad10aea7c050de (diff)
downloaddwarvish-c4cd1e2c165c4f34ebf67fa9350f8732b2aeca13.tar.gz
Updated the way built-in commands are called/used
Previously, built-in commands were fairly primitive, merely outputting STDOUT and STDERR with the print! macros. However, we need them to behave like normal programs, that is: - Acknowledge their verse's meter (forking, piping, etc.), - Ability to capture STDOUT and STDERR (>, 2>), - and Affect the currently running environment. For these reasons, the anthology was reworked, and now contains the Anthology struct, which mimics both std::process::{Child, Command}. The AnthologyStdin helper struct was also created, for built-ins to take input on STDIN, though no built-in is currently using it. Each built-ins' incant functions were updated to return a std::process::Output. It contains output from STDOUT, output from STDERR, and the exit code of the "process". A fix was also implemented for aliases, where the STDOUT and STDERR vectors were not being copied to the newly constructed verse.
Notes
Notes: There is some cleanup that needs to happen on this patch. For one, the spellcheck function is no longer being used, so there is a generic OS error if the program cannot be found in the $PATH. Also, anthology::lookup gets called twice, which shouldn't need to happen.
Diffstat (limited to 'src/compose')
-rw-r--r--src/compose/environment.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/compose/environment.rs b/src/compose/environment.rs
index ea6d070..18d59c4 100644
--- a/src/compose/environment.rs
+++ b/src/compose/environment.rs
@@ -24,6 +24,7 @@ use std::collections::HashMap;
/// ()
/// }
/// ```
+#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Environment {
pub aliases: HashMap<String, String>,
pub bins: Vec<String>,