@@ -3,12 +3,14 @@ use colored::*;
33use hacker:: { display_ascii, handle_run, handle_system, handle_unpack, handle_update, play_game, run_command_with_spinner, RunCommands , SystemCommands , UnpackCommands } ;
44use std:: process:: Command ;
55use 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" ) ]
89struct Cli {
910 #[ command( subcommand) ]
1011 command : Commands ,
1112}
13+
1214#[ derive( Subcommand ) ]
1315enum 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+
6873fn 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