Skip to content

Commit dfe5ad9

Browse files
authored
Update main.rs
1 parent e004b1b commit dfe5ad9

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

hacker/src/main.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use clap::{Parser, Subcommand};
22
use colored::*;
3-
use hacker::{display_ascii, handle_run, handle_system, handle_unpack, handle_update, play_game, run_command_with_spinner, RunCommands, SystemCommands, UnpackCommands};
3+
use hacker::{display_ascii, handle_run, handle_system, handle_unpack, play_game, run_command_with_spinner, RunCommands, SystemCommands, UnpackCommands};
44
use std::process::Command;
55
use std::io::{self, Write};
6-
76
#[derive(Parser)]
87
#[command(name = "hacker", about = "A vibrant CLI tool for managing hacker tools, gaming, and system utilities", version = "1.4.0")]
98
struct Cli {
109
#[command(subcommand)]
1110
command: Commands,
1211
}
13-
1412
#[derive(Subcommand)]
1513
enum Commands {
1614
/// Unpack various toolsets and applications
@@ -71,18 +69,17 @@ enum Commands {
7169
container: String,
7270
},
7371
}
74-
7572
fn main() {
7673
let cli = Cli::parse();
7774
match cli.command {
7875
Commands::Unpack { unpack_command } => handle_unpack(unpack_command),
7976
Commands::Help | Commands::HelpUi => {
8077
let home = std::env::var("HOME").unwrap_or_default();
81-
let help_bin = format!("{}/.hackeros/hacker-help", home);
78+
let help_bin = format!("{}/.hackeros/hacker/hacker-help", home);
8279
match Command::new(&help_bin).status() {
8380
Ok(status) => {
8481
if !status.success() {
85-
println!("{}", "Error running hacker-help. Ensure it's installed and executable in ~/.hackeros/".red().bold().on_black());
82+
println!("{}", "Error running hacker-help. Ensure it's installed and executable in ~/.hackeros/hacker/".red().bold().on_black());
8683
}
8784
}
8885
Err(e) => {
@@ -92,11 +89,11 @@ fn main() {
9289
}
9390
Commands::Docs => {
9491
let home = std::env::var("HOME").unwrap_or_default();
95-
let docs_bin = format!("{}/.hackeros/hacker-docs", home);
92+
let docs_bin = format!("{}/.hackeros/hacker/hacker-docs", home);
9693
match Command::new(&docs_bin).status() {
9794
Ok(status) => {
9895
if !status.success() {
99-
println!("{}", "Error running hacker-docs. Ensure it's installed and executable in ~/.hackeros/".red().bold().on_black());
96+
println!("{}", "Error running hacker-docs. Ensure it's installed and executable in ~/.hackeros/hacker/".red().bold().on_black());
10097
}
10198
}
10299
Err(e) => {
@@ -111,7 +108,20 @@ fn main() {
111108
Commands::FlatpakUpdate => run_command_with_spinner("flatpak", vec!["update", "-y"], "Running flatpak update"),
112109
Commands::System { system_command } => handle_system(system_command),
113110
Commands::Run { run_command } => handle_run(run_command),
114-
Commands::Update => handle_update(),
111+
Commands::Update => {
112+
let home = std::env::var("HOME").unwrap_or_default();
113+
let updater_bin = format!("{}/.hackeros/hacker/HackerOS-Updater", home);
114+
match Command::new(&updater_bin).status() {
115+
Ok(status) => {
116+
if !status.success() {
117+
println!("{}", "Error running HackerOS-Updater. Ensure it's installed and executable in ~/.hackeros/hacker/".red().bold().on_black());
118+
}
119+
}
120+
Err(e) => {
121+
println!("{}", format!("Failed to execute HackerOS-Updater: {}", e).red().bold().on_black());
122+
}
123+
}
124+
}
115125
Commands::Game => play_game(),
116126
Commands::HackerLang => {
117127
println!("{}", "========== Hacker Programming Language ==========".magenta().bold().on_black());
@@ -123,11 +133,11 @@ fn main() {
123133
Commands::Ascii => display_ascii(),
124134
Commands::Shell => {
125135
let home = std::env::var("HOME").unwrap_or_default();
126-
let shell_bin = format!("{}/.hackeros/hacker-shell", home);
136+
let shell_bin = format!("{}/.hackeros/hacker/hacker-shell", home);
127137
match Command::new(&shell_bin).status() {
128138
Ok(status) => {
129139
if !status.success() {
130-
println!("{}", "Error running hacker-shell. Ensure it's installed and executable in ~/.hackeros/".red().bold().on_black());
140+
println!("{}", "Error running hacker-shell. Ensure it's installed and executable in ~/.hackeros/hacker/".red().bold().on_black());
131141
}
132142
}
133143
Err(e) => {

0 commit comments

Comments
 (0)