diff --git a/Cargo.lock b/Cargo.lock index fb0d93c..4279ee4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "actionfile" -version = "0.2.8" +version = "0.2.9" dependencies = [ "colored", "prettytable", diff --git a/Cargo.toml b/Cargo.toml index 8a541e5..dce2d33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actionfile" -version = "0.2.8" +version = "0.2.9" edition = "2021" license = "MIT" diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6487a87..4c91ea5 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,6 +1,7 @@ pub mod add; pub mod install; pub mod list_commands; +pub mod outdated; pub mod remove; pub mod upgrade; pub mod version; diff --git a/src/commands/outdated.rs b/src/commands/outdated.rs new file mode 100644 index 0000000..2e1d9be --- /dev/null +++ b/src/commands/outdated.rs @@ -0,0 +1,3 @@ +pub async fn outdated() { + todo!() +} diff --git a/src/commands/version.rs b/src/commands/version.rs index 8c6c6ac..76f8085 100644 --- a/src/commands/version.rs +++ b/src/commands/version.rs @@ -1,4 +1,4 @@ pub async fn version() { let version = env!("CARGO_PKG_VERSION"); - println!("Version: {}", version); + println!("{}", version); } diff --git a/src/main.rs b/src/main.rs index b966cba..cccfac6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,6 +70,10 @@ async fn main() { let _ = commands::remove::remove_packages().await; return; } + "outdated" | "o" => { + let _ = commands::outdated::outdated().await; + return; + } "" => { let _ = run::run_command(&commands[0].value).await; return; diff --git a/src/package_detector.rs b/src/package_detector.rs index 11edc1c..4fff264 100644 --- a/src/package_detector.rs +++ b/src/package_detector.rs @@ -57,11 +57,15 @@ pub async fn return_remove_cmd() -> Result { match package_manager { PackageManager::Npm => Ok("npm uninstall".to_string()), PackageManager::Bun => Ok("bun rm".to_string()), - PackageManager::Deno => Ok("echo 'Deno does not supporting remove packages.'".to_string()), + PackageManager::Deno => Ok(not_supported("Deno").to_string()), PackageManager::Pnpm => Ok("pnpm rm".to_string()), PackageManager::Yarn => Ok("yarn remove".to_string()), - PackageManager::Go => Ok("go uninstall".to_string()), - PackageManager::Cargo => Ok("cargo remove".to_string()), + PackageManager::Go => Ok(not_supported("Go").to_string()), + PackageManager::Cargo => Ok(not_supported("Cargo").to_string()), PackageManager::Pip => Ok("pip uninstall".to_string()), } } + +fn not_supported(name: &str) -> String { + format!("echo \"{} is not supported\"", name) +} diff --git a/src/run.rs b/src/run.rs index 683c5af..7252ef4 100644 --- a/src/run.rs +++ b/src/run.rs @@ -5,27 +5,15 @@ use tracing::error; pub async fn run_command(command: &str) -> Result<(), String> { let os = std::env::consts::OS; - let mut child = if os == "windows" { - Command::new("cmd") - .env("FORCE_COLOR", "true") - .env("CLICOLOR_FORCE", "1") - .arg("/c") - .arg(command) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .expect("Failed to start command") - } else { - Command::new("bash") - .env("FORCE_COLOR", "true") - .env("CLICOLOR_FORCE", "1") - .arg("-c") - .arg(command) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .expect("Failed to start command") - }; + let is_windows = os == "windows"; + + let mut child = Command::new(if is_windows { "cmd" } else { "bash" }) + .arg(if is_windows { "/c" } else { "-c" }) + .arg(command) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("Failed to start command"); // handle realtime stdout if let Some(stdout) = child.stdout.take() {