Use color_eyre (#173)

This commit is contained in:
Rebecca Turner
2022-11-11 09:39:29 -05:00
committed by Thomas Schönauer
parent e84173be8f
commit 2cbb7db66d
34 changed files with 216 additions and 72 deletions

View File

@@ -1,4 +1,6 @@
use anyhow::{Context, Result};
use color_eyre::eyre::eyre;
use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use crate::command::CommandExt;
use crate::error::{self, TopgradeError};
@@ -108,6 +110,6 @@ pub fn run_containers(ctx: &ExecutionContext) -> Result<()> {
if success {
Ok(())
} else {
Err(anyhow::anyhow!(error::StepFailed))
Err(eyre!(error::StepFailed))
}
}

View File

@@ -2,7 +2,7 @@
use std::env;
use std::path::{Path, PathBuf};
use anyhow::Result;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use crate::command::CommandExt;

View File

@@ -5,7 +5,9 @@ use std::process::Command;
use std::{env, path::Path};
use std::{fs, io::Write};
use anyhow::{Context, Result};
use color_eyre::eyre::eyre;
use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use log::debug;
use tempfile::tempfile_in;
@@ -154,7 +156,7 @@ pub fn run_micro(run_type: RunType) -> Result<()> {
if stdout.contains("Nothing to install / update") || stdout.contains("One or more plugins installed") {
Ok(())
} else {
Err(anyhow::anyhow!("micro output does not indicate success: {}", stdout))
Err(eyre!("micro output does not indicate success: {}", stdout))
}
}

View File

@@ -3,7 +3,7 @@ use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Output, Stdio};
use anyhow::{anyhow, Result};
use color_eyre::eyre::{eyre, Result};
use console::style;
use futures::stream::{iter, FuturesUnordered};
use futures::StreamExt;
@@ -37,7 +37,7 @@ pub struct Repositories<'a> {
fn output_checked_utf8(output: Output) -> Result<()> {
if !(output.status.success()) {
let stderr = String::from_utf8(output.stderr).unwrap();
Err(anyhow!(stderr))
Err(eyre!(stderr))
} else {
Ok(())
}

View File

@@ -1,6 +1,6 @@
use crate::terminal::print_separator;
use crate::utils::require;
use anyhow::Result;
use color_eyre::eyre::Result;
use crate::execution_context::ExecutionContext;

View File

@@ -4,7 +4,7 @@ use std::os::unix::fs::MetadataExt;
use std::path::PathBuf;
use std::process::Command;
use anyhow::Result;
use color_eyre::eyre::Result;
use log::debug;
#[cfg(target_os = "linux")]
use nix::unistd::Uid;

View File

@@ -2,7 +2,7 @@ use crate::execution_context::ExecutionContext;
use crate::terminal::print_separator;
use crate::utils::require;
use crate::Step;
use anyhow::Result;
use color_eyre::eyre::Result;
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
//let pkg = require("pkg")?;

View File

@@ -3,7 +3,8 @@ use std::ffi::OsString;
use std::path::{Path, PathBuf};
use std::process::Command;
use anyhow::Result;
use color_eyre::eyre;
use color_eyre::eyre::Result;
use walkdir::WalkDir;
use crate::command::CommandExt;
@@ -301,7 +302,7 @@ pub fn get_arch_package_manager(ctx: &ExecutionContext) -> Option<Box<dyn ArchPa
pub fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
let package_manager =
get_arch_package_manager(ctx).ok_or_else(|| anyhow::Error::from(TopgradeError::FailedGettingPackageManager))?;
get_arch_package_manager(ctx).ok_or_else(|| eyre::Report::from(TopgradeError::FailedGettingPackageManager))?;
package_manager.upgrade(ctx)
}

View File

@@ -1,7 +1,7 @@
use crate::executor::RunType;
use crate::terminal::print_separator;
use crate::utils::require_option;
use anyhow::Result;
use color_eyre::eyre::Result;
use std::path::PathBuf;
use std::process::Command;

View File

@@ -1,7 +1,7 @@
use crate::executor::RunType;
use crate::terminal::print_separator;
use crate::utils::require_option;
use anyhow::Result;
use color_eyre::eyre::Result;
use std::path::PathBuf;
use std::process::Command;

View File

@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};
use std::process::Command;
use anyhow::Result;
use color_eyre::eyre::Result;
use ini::Ini;
use log::{debug, warn};

View File

@@ -3,7 +3,7 @@ use crate::execution_context::ExecutionContext;
use crate::executor::RunType;
use crate::terminal::{print_separator, prompt_yesno};
use crate::{utils::require, Step};
use anyhow::Result;
use color_eyre::eyre::Result;
use log::debug;
use std::fs;
use std::process::Command;

View File

@@ -1,7 +1,7 @@
use crate::executor::RunType;
use crate::terminal::print_separator;
use crate::utils::require_option;
use anyhow::Result;
use color_eyre::eyre::Result;
use std::path::PathBuf;
pub fn upgrade_openbsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {

View File

@@ -6,7 +6,7 @@ use std::{env, path::Path};
use crate::command::CommandExt;
use crate::Step;
use anyhow::Result;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use home;
use ini::Ini;

View File

@@ -2,7 +2,7 @@ use std::convert::TryFrom;
use std::path::Path;
use std::{ffi::OsStr, process::Command};
use anyhow::Result;
use color_eyre::eyre::Result;
use log::debug;
use crate::command::CommandExt;

View File

@@ -3,7 +3,7 @@ use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use anyhow::Result;
use color_eyre::eyre::Result;
use crate::command::CommandExt;
use crate::execution_context::ExecutionContext;

View File

@@ -1,4 +1,4 @@
use anyhow::Result;
use color_eyre::eyre::Result;
use crate::{
command::CommandExt, error::SkipStep, execution_context::ExecutionContext, terminal::print_separator, utils,

View File

@@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::{fmt::Display, rc::Rc, str::FromStr};
use anyhow::Result;
use color_eyre::eyre::Result;
use log::{debug, error};
use regex::Regex;
use strum::EnumString;

View File

@@ -2,7 +2,7 @@ use std::env;
use std::path::PathBuf;
use std::process::{exit, Command};
use anyhow::Result;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use crate::command::CommandExt;

View File

@@ -1,4 +1,4 @@
use anyhow::Result;
use color_eyre::eyre::Result;
use crate::command::CommandExt;
use crate::config::Step;

View File

@@ -1,6 +1,6 @@
use crate::command::CommandExt;
use crate::error::{SkipStep, TopgradeError};
use anyhow::Result;
use color_eyre::eyre::Result;
use crate::executor::{Executor, ExecutorOutput, RunType};
use crate::terminal::print_separator;

View File

@@ -2,7 +2,7 @@ use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
use anyhow::Result;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use log::debug;
use walkdir::WalkDir;