Skip to content

Commit 6356a86

Browse files
authored
Update main.rs
1 parent 102718a commit 6356a86

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

hacker/src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ use colored::*;
33
use hacker::{display_ascii, handle_run, handle_system, handle_unpack, handle_update, play_game, run_command_with_spinner, RunCommands, SystemCommands, UnpackCommands};
44
use std::process::Command;
55
use std::io::{self, Write};
6+
67
#[derive(Parser)]
78
#[command(name = "hacker", about = "A vibrant CLI tool for managing hacker tools, gaming, and system utilities", version = "1.1.0")]
89
struct Cli {
910
#[command(subcommand)]
1011
command: Commands,
1112
}
13+
1214
#[derive(Subcommand)]
1315
enum Commands {
1416
/// Unpack various toolsets and applications
@@ -18,6 +20,8 @@ enum Commands {
1820
},
1921
/// Display help information and list available commands
2022
Help,
23+
/// Display help information in UI
24+
HelpUi,
2125
/// Install a package using apt
2226
Install {
2327
package: String,
@@ -65,6 +69,7 @@ enum Commands {
6569
container: String,
6670
},
6771
}
72+
6873
fn main() {
6974
let cli = Cli::parse();
7075
match cli.command {
@@ -83,6 +88,20 @@ fn main() {
8388
}
8489
}
8590
}
91+
Commands::HelpUi => {
92+
let home = std::env::var("HOME").unwrap_or_default();
93+
let help_bin = format!("{}/.hackeros/hacker-help", home);
94+
match Command::new(&help_bin).status() {
95+
Ok(status) => {
96+
if !status.success() {
97+
println!("{}", "Error running hacker-help. Ensure it's installed and executable in ~/.hackeros/".red().bold().on_black());
98+
}
99+
}
100+
Err(e) => {
101+
println!("{}", format!("Failed to execute hacker-help: {}", e).red().bold().on_black());
102+
}
103+
}
104+
}
86105
Commands::Install { package } => run_command_with_spinner("sudo", vec!["apt", "install", "-y", &package], "Running apt install"),
87106
Commands::Remove { package } => run_command_with_spinner("sudo", vec!["apt", "remove", "-y", &package], "Running apt remove"),
88107
Commands::FlatpakInstall { package } => run_command_with_spinner("flatpak", vec!["install", "-y", "flathub", &package], "Running flatpak install"),

0 commit comments

Comments
 (0)