summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary/runcmd.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-03 06:16:07 +0000
committerLars Wirzenius <liw@liw.fi>2022-01-03 06:16:07 +0000
commit0734368d45b349a6ab433c1d41f35a95ea58c9ec (patch)
treeb69c6b84b9ce025d6f7afd92d734452757f4f365 /subplotlib/src/steplibrary/runcmd.rs
parente8082fef03bd04042dad3fb2d0513587c54874ab (diff)
parentb9de4d5e810d07b679ad9ab9e46d58e4c76213cc (diff)
downloadsubplot-0734368d45b349a6ab433c1d41f35a95ea58c9ec.tar.gz
Merge branch 'more-rust-subplots' into 'main'
codegen: Refuse to generate code if the specified template is not present Closes #259 See merge request subplot/subplot!242
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]