@@ -4,14 +4,11 @@ use std::io::{self, Write};
44use std:: thread;
55use std:: time:: Duration ;
66use std:: sync:: { Arc , atomic:: { AtomicBool , Ordering } } ;
7-
87pub fn run_command_with_spinner ( program : & str , args : Vec < & str > , message : & str ) {
98 println ! ( "{}" , format!( "{}: {}" , message, args. join( " " ) ) . blue( ) . bold( ) . on_black( ) ) ;
10-
119 let stop = Arc :: new ( AtomicBool :: new ( false ) ) ;
1210 let stop_clone = stop. clone ( ) ;
1311 let spinner_chars: Vec < & str > = vec ! [ "⠋" , "⠙" , "⠹" , "⠸" , "⠼" , "⠴" , "⠦" , "⠧" , "⠇" , "⠏" ] ;
14-
1512 let handle = thread:: spawn ( move || {
1613 let mut i = 0 ;
1714 while !stop_clone. load ( Ordering :: Relaxed ) {
@@ -23,26 +20,21 @@ pub fn run_command_with_spinner(program: &str, args: Vec<&str>, message: &str) {
2320 print ! ( "\r \r " ) ;
2421 let _ = io:: stdout ( ) . flush ( ) ;
2522 } ) ;
26-
2723 let child = Command :: new ( program)
2824 . args ( & args)
2925 . stdout ( Stdio :: piped ( ) )
3026 . stderr ( Stdio :: piped ( ) )
3127 . spawn ( )
3228 . expect ( & format ! ( "Failed to execute {}" , program) ) ;
33-
3429 let output = child. wait_with_output ( ) . expect ( "Failed to wait on child" ) ;
35-
3630 stop. store ( true , Ordering :: Relaxed ) ;
3731 handle. join ( ) . unwrap ( ) ;
38-
3932 if output. status . success ( ) {
4033 println ! ( "{}" , String :: from_utf8_lossy( & output. stdout) . green( ) . bold( ) . on_black( ) ) ;
4134 } else {
4235 println ! ( "{}" , String :: from_utf8_lossy( & output. stderr) . red( ) . bold( ) . on_black( ) ) ;
4336 }
4437}
45-
4638pub fn handle_update ( ) {
4739 println ! ( "{}" , "========== Starting System Update ==========" . magenta( ) . bold( ) . on_black( ) ) ;
4840 run_command_with_spinner ( "sudo" , vec ! [ "apt" , "update" ] , "Updating APT repositories" ) ;
@@ -52,7 +44,6 @@ pub fn handle_update() {
5244 run_command_with_spinner ( "fwupdmgr" , vec ! [ "update" ] , "Updating firmware" ) ;
5345 println ! ( "{}" , "========== System Update Complete ==========" . green( ) . bold( ) . on_black( ) ) ;
5446}
55-
5647pub fn handle_cybersecurity ( ) {
5748 println ! ( "{}" , "========== Installing Penetration Tools ==========" . cyan( ) . bold( ) . on_black( ) ) ;
5849 run_command_with_spinner ( "flatpak" , vec ! [ "remote-add" , "--if-not-exists" , "flathub" , "https://dl.flathub.org/repo/flathub.flatpakrepo" ] , "Adding flathub repo" ) ;
@@ -63,7 +54,6 @@ pub fn handle_cybersecurity() {
6354 run_command_with_spinner ( "flatpak" , vec ! [ "install" , "-y" , "flathub" , "org.ghidra_sre.Ghidra" ] , "Installing Ghidra" ) ;
6455 println ! ( "{}" , "========== Hacker-Unpack-Cybersecurity Complete ==========" . green( ) . bold( ) . on_black( ) ) ;
6556}
66-
6757pub fn handle_gaming ( ) {
6858 println ! ( "{}" , "========== Installing Gaming Tools ==========" . cyan( ) . bold( ) . on_black( ) ) ;
6959 run_command_with_spinner ( "flatpak" , vec ! [ "remote-add" , "--if-not-exists" , "flathub" , "https://dl.flathub.org/repo/flathub.flatpakrepo" ] , "Adding flathub repo" ) ;
0 commit comments