Update libs

This commit is contained in:
Noah Knegt
2025-05-08 16:48:10 +02:00
parent a2f2e303a0
commit 347d71d9de
10 changed files with 202 additions and 159 deletions

View File

@@ -1,6 +1,7 @@
[package]
name = "command-with-spinner"
version = "0.1.0"
edition.workspace = true
authors.workspace = true
license-file.workspace = true
@@ -9,5 +10,5 @@ repository.workspace = true
[dependencies]
anyhow = "1.0.98"
colored = "3.0.0"
git = { version = "0.1.0", path = "../git" }
indicatif = "0.17.11"
thiserror = "2.0"

View File

@@ -0,0 +1,12 @@
/// Git operations error type
#[derive(Debug, thiserror::Error)]
pub enum CommandError {
#[error("Command failed with exit code: {0}")]
Failed(i32),
#[error("Command failed without exit code")]
FailedNoCode,
#[error("Failed to execute command: {0}")]
ExecutionError(#[from] std::io::Error),
}

View File

@@ -4,7 +4,8 @@ use anyhow::{Context, Result};
use colored::*;
use indicatif::{ProgressBar, ProgressStyle};
use git::error::GitError;
mod error;
use error::CommandError;
/// Runs a git command with a progress spinner
pub fn run_command(command: &mut Command, message: &str) -> Result<()> {
@@ -34,8 +35,8 @@ pub fn run_command(command: &mut Command, message: &str) -> Result<()> {
let code = status.code();
match code {
Some(code) => Err(GitError::Failed(code).into()),
None => Err(GitError::FailedNoCode.into()),
Some(code) => Err(CommandError::Failed(code).into()),
None => Err(CommandError::FailedNoCode.into()),
}
}
}