build_pretty/
command_builder.rs

1use super::*;
2
3pub struct CommandBuilder
4{
5 c: Command
6}
7
8impl CommandBuilder
9{
10 pub fn new<S: AsRef<str>>(command: S) -> Self
11 {
12  Self {
13   c: Command::new(command.as_ref())
14  }
15 }
16
17 pub fn new_with_args<S>(command: S, args: &[S]) -> Self
18 where S: AsRef<str> + std::convert::AsRef<std::ffi::OsStr>
19 {
20  let s = Self::new(command);
21  s.with_args(args)
22 }
23
24 pub fn with_args<S>(mut self, args: &[S]) -> Self
25 where S: AsRef<str> + std::convert::AsRef<std::ffi::OsStr>
26 {
27  self.c.args(args);
28  self
29 }
30
31 pub fn new_with_arg<S>(command: S, arg: S) -> Self
32 where S: AsRef<str> + std::convert::AsRef<std::ffi::OsStr>
33 {
34  let s = Self::new(command);
35  s.with_arg(arg)
36 }
37
38 pub fn with_arg<S>(mut self, arg: S) -> Self
39 where S: AsRef<str> + std::convert::AsRef<std::ffi::OsStr>
40 {
41  self.c.arg(arg);
42  self
43 }
44}
45
46impl Into<Command> for CommandBuilder
47{
48 fn into(self) -> Command { self.c }
49}