blob: bb66f313fcf8c0737dee61b4d7220bdedde235f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use std::ffi::OsStr;
use std::process::*;
/// A wrapper around `std::process::Command` to simplify command construction.
pub struct CommandBuilder {
command: Command,
}
impl CommandBuilder {
pub fn new(program: impl AsRef<OsStr>) -> CommandBuilder {
Self {
command: Command::new(program),
}
}
pub fn args<I, S>(mut self, args: I) -> CommandBuilder
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
self.command.args(args);
self
}
pub fn silent(mut self) -> CommandBuilder {
self.command.stdout(Stdio::null()).stderr(Stdio::null());
self
}
pub fn build(self) -> Command {
self.command
}
}
|