summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-05-30 21:39:20 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-12-27 14:27:58 +0000
commit32bc1e9aaa2b8a6a08c27d8b8fda838d741766b9 (patch)
treefc661d9a8e83a7002df90173da945ef735cb56fa /subplotlib
parent689eb6665eca5bf2a86ddb3c40e25e438dd72d0a (diff)
downloadsubplot-32bc1e9aaa2b8a6a08c27d8b8fda838d741766b9.tar.gz
runcmd: Add stdout/stderr accessors
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/src/steplibrary/runcmd.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/subplotlib/src/steplibrary/runcmd.rs b/subplotlib/src/steplibrary/runcmd.rs
index f42df6e..5fc12eb 100644
--- a/subplotlib/src/steplibrary/runcmd.rs
+++ b/subplotlib/src/steplibrary/runcmd.rs
@@ -67,9 +67,24 @@ impl ContextElement for Runcmd {
}
impl Runcmd {
+ /// Prepend the given location to the run path
pub fn prepend_to_path<S: Into<OsString>>(&mut self, element: S) {
self.paths.push(element.into());
}
+
+ /// Retrieve the last run command's stdout as a string.
+ ///
+ /// This does a lossy conversion from utf8 so should always succeed.
+ pub fn stdout_as_string(&self) -> String {
+ String::from_utf8_lossy(&self.stdout).into_owned()
+ }
+
+ /// Retrieve the last run command's stderr as a string.
+ ///
+ /// This does a lossy conversion from utf8 so should always succeed.
+ pub fn stderr_as_string(&self) -> String {
+ String::from_utf8_lossy(&self.stderr).into_owned()
+ }
}
#[step]