Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejlv committed Feb 4, 2025
1 parent 23e1bb7 commit 520adf6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actionfile"
version = "0.2.8"
version = "0.2.9"
edition = "2021"
license = "MIT"

Expand Down
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions src/commands/outdated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub async fn outdated() {
todo!()
}
2 changes: 1 addition & 1 deletion src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub async fn version() {
let version = env!("CARGO_PKG_VERSION");
println!("Version: {}", version);
println!("{}", version);
}
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions src/package_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ pub async fn return_remove_cmd() -> Result<String, Error> {
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)
}
30 changes: 9 additions & 21 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 520adf6

Please sign in to comment.