Add CommandExt trait (#146)
* Color CI output * Improve `CommandExt` * Add comments explaining `#[allow]`s * Remove useless `dead_code` annotation * Improve error messages * Print errors when running a shell errors * fixup! Remove useless `dead_code` annotation
This commit is contained in:
committed by
Thomas Schönauer
parent
bd34a3bcd4
commit
e84173be8f
@@ -1,7 +1,8 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::error::{SkipStep, TopgradeError};
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::executor::{CommandExt, Executor, ExecutorOutput, RunType};
|
||||
use crate::executor::{Executor, ExecutorOutput, RunType};
|
||||
use crate::terminal::print_separator;
|
||||
use crate::{
|
||||
execution_context::ExecutionContext,
|
||||
@@ -63,7 +64,7 @@ fn upgrade(command: &mut Executor, ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
if !status.success() {
|
||||
return Err(TopgradeError::ProcessFailed(status).into());
|
||||
return Err(TopgradeError::ProcessFailed(command.get_program(), status).into());
|
||||
} else {
|
||||
println!("Plugins upgraded")
|
||||
}
|
||||
@@ -84,22 +85,22 @@ pub fn upgrade_ultimate_vimrc(ctx: &ExecutionContext) -> Result<()> {
|
||||
.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["reset", "--hard"])
|
||||
.check_run()?;
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["clean", "-d", "--force"])
|
||||
.check_run()?;
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(&git)
|
||||
.current_dir(&config_dir)
|
||||
.args(["pull", "--rebase"])
|
||||
.check_run()?;
|
||||
.status_checked()?;
|
||||
ctx.run_type()
|
||||
.execute(python)
|
||||
.current_dir(config_dir)
|
||||
.arg(update_plugins)
|
||||
.check_run()?;
|
||||
.status_checked()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -107,8 +108,8 @@ pub fn upgrade_ultimate_vimrc(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn upgrade_vim(base_dirs: &BaseDirs, ctx: &ExecutionContext) -> Result<()> {
|
||||
let vim = require("vim")?;
|
||||
|
||||
let output = Command::new(&vim).arg("--version").check_output()?;
|
||||
if !output.starts_with("VIM") {
|
||||
let output = Command::new(&vim).arg("--version").output_checked_utf8()?;
|
||||
if !output.stdout.starts_with("VIM") {
|
||||
return Err(SkipStep(String::from("vim binary might be actually nvim")).into());
|
||||
}
|
||||
|
||||
@@ -147,5 +148,5 @@ pub fn run_voom(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||
|
||||
print_separator("voom");
|
||||
|
||||
run_type.execute(voom).arg("update").check_run()
|
||||
run_type.execute(voom).arg("update").status_checked()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user