summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary/runcmd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'subplotlib/src/steplibrary/runcmd.rs')
-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]