1use std::ffi::OsString;
2use std::process::Command;
3
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct ProgramArgs {
8 program: OsString,
9 args: Vec<OsString>,
10}
11impl ProgramArgs {
12 #[inline]
14 pub fn new<S: Into<OsString>>(program: S) -> ProgramArgs {
15 ProgramArgs {
16 program: program.into(),
17 args: Vec::new(),
18 }
19 }
20
21 #[inline]
23 pub fn push<S: Into<OsString>>(&mut self, arg: S) {
24 self.args.push(arg.into());
25 }
26
27 pub fn into_command(self) -> Command {
29 let mut cmd = Command::new(&self.program);
30 cmd.args(&self.args);
31 cmd
32 }
33}
34impl<S: Into<OsString>> Extend<S> for ProgramArgs {
35 fn extend<T: IntoIterator<Item = S>>(&mut self, iterable: T) {
36 self.args.extend(iterable.into_iter().map(Into::into));
37 }
38}