@@ -37,13 +37,13 @@ pub enum OutputMode {
37
37
/// [allow_failure]: BootstrapCommand::allow_failure
38
38
/// [delay_failure]: BootstrapCommand::delay_failure
39
39
#[derive(Debug)]
40
- pub struct BootstrapCommand<'a> {
41
- pub command: &'a mut Command,
40
+ pub struct BootstrapCommand {
41
+ pub command: Command,
42
42
pub failure_behavior: BehaviorOnFailure,
43
43
pub output_mode: Option<OutputMode>,
44
44
}
45
45
46
- impl<'a> BootstrapCommand<'a> {
46
+ impl BootstrapCommand {
47
47
pub fn delay_failure(self) -> Self {
48
48
Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
49
49
}
@@ -66,8 +66,33 @@ impl<'a> BootstrapCommand<'a> {
66
66
}
67
67
}
68
68
69
- impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
69
+ /// This implementation is temporary, until all `Command` invocations are migrated to
70
+ /// `BootstrapCommand`.
71
+ impl<'a> From<&'a mut Command> for BootstrapCommand {
70
72
fn from(command: &'a mut Command) -> Self {
73
+ // This is essentially a manual `Command::clone`
74
+ let mut cmd = Command::new(command.get_program());
75
+ if let Some(dir) = command.get_current_dir() {
76
+ cmd.current_dir(dir);
77
+ }
78
+ cmd.args(command.get_args());
79
+ for (key, value) in command.get_envs() {
80
+ match value {
81
+ Some(value) => {
82
+ cmd.env(key, value);
83
+ }
84
+ None => {
85
+ cmd.env_remove(key);
86
+ }
87
+ }
88
+ }
89
+
90
+ cmd.into()
91
+ }
92
+ }
93
+
94
+ impl From<Command> for BootstrapCommand {
95
+ fn from(command: Command) -> Self {
71
96
Self { command, failure_behavior: BehaviorOnFailure::Exit, output_mode: None }
72
97
}
73
98
}
0 commit comments