refactor: move RunType::execute to ExecutionContext
This commit is contained in:
@@ -35,7 +35,7 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
|
||||
unreachable!("Tmux execution is only implemented in Unix");
|
||||
} else if ctx.config().open_remotes_in_new_terminal() && !ctx.run_type().dry() && cfg!(windows) {
|
||||
prepare_async_ssh_command(&mut args);
|
||||
ctx.run_type().execute("wt").args(&args).spawn()?;
|
||||
ctx.execute("wt").args(&args).spawn()?;
|
||||
Err(SkipStep(String::from(t!("Remote Topgrade launched in an external terminal"))).into())
|
||||
} else {
|
||||
let mut args = vec!["-t", hostname];
|
||||
@@ -50,6 +50,6 @@ pub fn ssh_step(ctx: &ExecutionContext, hostname: &str) -> Result<()> {
|
||||
print_separator(format!("Remote ({hostname})"));
|
||||
println!("{}", t!("Connecting to {hostname}...", hostname = hostname));
|
||||
|
||||
ctx.run_type().execute(ssh).args(&args).status_checked()
|
||||
ctx.execute(ssh).args(&args).status_checked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,7 @@ impl<'a> TemporaryPowerOn<'a> {
|
||||
BoxStatus::Running => unreachable!(),
|
||||
};
|
||||
|
||||
ctx.run_type()
|
||||
.execute(vagrant)
|
||||
ctx.execute(vagrant)
|
||||
.args([subcommand, &vagrant_box.name])
|
||||
.current_dir(vagrant_box.path.clone())
|
||||
.status_checked()?;
|
||||
@@ -141,7 +140,6 @@ impl Drop for TemporaryPowerOn<'_> {
|
||||
|
||||
println!();
|
||||
self.ctx
|
||||
.run_type()
|
||||
.execute(self.vagrant)
|
||||
.args([subcommand, &self.vagrant_box.name])
|
||||
.current_dir(self.vagrant_box.path.clone())
|
||||
@@ -202,8 +200,7 @@ pub fn topgrade_vagrant_box(ctx: &ExecutionContext, vagrant_box: &VagrantBox) ->
|
||||
command.push_str(" -y");
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&vagrant.path)
|
||||
ctx.execute(&vagrant.path)
|
||||
.current_dir(&vagrant_box.path)
|
||||
.args(["ssh", "-c", &command])
|
||||
.status_checked()
|
||||
@@ -223,7 +220,6 @@ pub fn upgrade_vagrant_boxes(ctx: &ExecutionContext) -> Result<()> {
|
||||
for ele in re.captures_iter(&outdated.stdout) {
|
||||
found = true;
|
||||
let _ = ctx
|
||||
.run_type()
|
||||
.execute(&vagrant)
|
||||
.args(["box", "update", "--box"])
|
||||
.arg(ele.get(1).unwrap().as_str())
|
||||
@@ -235,10 +231,7 @@ pub fn upgrade_vagrant_boxes(ctx: &ExecutionContext) -> Result<()> {
|
||||
if !found {
|
||||
println!("{}", t!("No outdated boxes"));
|
||||
} else {
|
||||
ctx.run_type()
|
||||
.execute(&vagrant)
|
||||
.args(["box", "prune"])
|
||||
.status_checked()?;
|
||||
ctx.execute(&vagrant).args(["box", "prune"]).status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user