This commit is contained in:
Bojan Serafimov
2022-08-18 15:16:14 -04:00
parent 4e91ff31ca
commit 1501dbd5a5
8 changed files with 116 additions and 52 deletions
+21
View File
@@ -0,0 +1,21 @@
use std::path::PathBuf;
use std::{os::unix::prelude::CommandExt, process::Command};
use std::fs::File;
pub trait NeonCommandExtensions: CommandExt {
fn capture_to_files(&mut self, path: PathBuf, name: &str) -> &mut Command;
}
impl NeonCommandExtensions for Command {
fn capture_to_files(&mut self, path: PathBuf, name: &str) -> &mut Command {
let out_file = File::create(path.join(format!("{}.out", name)))
.expect("can't make file");
let err_file = File::create(path.join(format!("{}.out", name)))
.expect("can't make file");
// TODO touch files?
self.stdout(out_file).stderr(err_file)
}
}
+3
View File
@@ -54,6 +54,9 @@ pub mod nonblock;
// Default signal handling
pub mod signals;
// Helpers for running commands
pub mod command_extensions;
/// This is a shortcut to embed git sha into binaries and avoid copying the same build script to all packages
///
/// we have several cases:
+10
View File
@@ -0,0 +1,10 @@
use std::{os::unix::prelude::CommandExt, process::Command};
/// Command with ability to capture stdout and stderr to files
trait CaptureOutputToFile: CommandExt {
fn capture_to_file(&mut self) -> &mut Command;
}
impl<C: CommandExt> CaptureOutputToFile
View File