1use oclif::{term::ERR_YELLOW, CliError};
2use thiserror::Error;
3
4use std::io;
5
6#[doc(hidden)]
7#[derive(Error, Debug)]
8pub enum Error {
9 #[error("minimum version of {0} that should be upgraded from is {1}")]
10 NotMinimum(String, String),
11 #[error("{0}")]
12 Io(#[from] io::Error),
13 #[error("{0}")]
14 Any(#[from] anyhow::Error),
15}
16
17impl CliError for Error {
18 fn color(self) -> Self {
19 match self {
20 Self::NotMinimum(dep, min) => Self::NotMinimum(
21 ERR_YELLOW.apply_to(dep).to_string(),
22 ERR_YELLOW.apply_to(min).to_string(),
23 ),
24 _ => self,
25 }
26 }
27}
28
29pub(crate) const INTERNAL_ERR: &'static str =
30 "Internal error message. Please create an issue on https://github.com/automa-app/cargo-up";
31
32#[inline]
33pub(crate) fn normalize(name: &str) -> String {
34 name.replace("-", "_")
35}