1- # binarka hacker-shell (main.py)
21from rich .console import Console
32from rich .panel import Panel
43from rich .text import Text
87from prompt_toolkit .styles import Style
98import subprocess
109import sys
10+ import os
11+
1112console = Console ()
13+
1214commands = [
13- "unpack addons " , "unpack gs" , "unpack devtools" , "unpack emulators" , "unpack cybersecurity" ,
14- "unpack select" , "unpack gaming" , "unpack noroblox" , "unpack hackermode " ,
15- "help" , "install " , "remove" , "apt- install" , "apt- remove" ,
15+ "unpack add-ons " , "unpack gs" , "unpack devtools" , "unpack emulators" , "unpack cybersecurity" ,
16+ "unpack select" , "unpack gaming" , "unpack noroblox" , "unpack hacker-mode" , "unpack gamescope-session-steam " ,
17+ "help" , "docs " , "install" , "remove" ,
1618 "flatpak-install" , "flatpak-remove" , "flatpak-update" ,
1719 "system logs" ,
18- "run update-system" , "run check-updates" , "run steam" , "run hacker-launcher" , "run hackeros-game-mode" ,
19- "update" , "game" , "hacker-lang" , "ascii" , "shell" , "exit" ,
20- "enter" , "remove-container"
20+ "run update-system" , "run check-updates" , "run steam" , "run hacker-launcher" , "run hackeros-game-mode" , "run update-hackeros" ,
21+ "update" , "game" , "hacker-lang" , "ascii" , "shell" , "enter" , "remove-container" , "exit"
2122]
23+
2224completer = WordCompleter (commands , ignore_case = True )
25+
2326style = Style .from_dict ({
24- 'prompt' : 'cyan bold' ,
27+ 'prompt' : 'blue bold' ,
2528})
29+
2630def display_command_list ():
2731 console .clear ()
28- title = Text ("Hacker Shell - Commands (Expanded)" , style = "bold magenta " )
29- tree = Tree ("Available Commands" , style = "bold green " )
30- unpack = tree .add ("unpack: Unpack various toolsets" , style = "cyan " )
31- unpack .add ("addons , gs, devtools, emulators, cybersecurity (container), select (TUI), gaming, noroblox, hackermode " )
32+ title = Text ("Hacker Shell - Commands (Expanded)" , style = "bold purple " )
33+ tree = Tree ("Available Commands" , style = "bold blue " )
34+ unpack = tree .add ("unpack: Unpack various toolsets" , style = "blue " )
35+ unpack .add ("add-ons , gs, devtools, emulators, cybersecurity (container), select (TUI), gaming, noroblox, hacker-mode, gamescope-session-steam " )
3236 tree .add ("help: Display help (TUI)" )
37+ tree .add ("docs: Display documentation and FAQ (TUI)" )
3338 tree .add ("install <package>: APT install" )
3439 tree .add ("remove <package>: APT remove" )
3540 tree .add ("flatpak-install <package>" )
3641 tree .add ("flatpak-remove <package>" )
3742 tree .add ("flatpak-update" )
38- system = tree .add ("system: System commands" , style = "cyan " )
43+ system = tree .add ("system: System commands" , style = "blue " )
3944 system .add ("logs" )
40- run = tree .add ("run: Run scripts" , style = "cyan " )
41- run .add ("update-system, check-updates, steam, hacker-launcher, hackeros-game-mode" )
45+ run = tree .add ("run: Run scripts" , style = "blue " )
46+ run .add ("update-system, check-updates, steam, hacker-launcher, hackeros-game-mode, update-hackeros " )
4247 tree .add ("update: Full system update" )
4348 tree .add ("game: Play expanded Hacker Adventure" )
4449 tree .add ("hacker-lang: Info on Hacker lang" )
@@ -47,31 +52,44 @@ def display_command_list():
4752 tree .add ("enter <container>: Enter distrobox container" )
4853 tree .add ("remove-container <container>: Remove distrobox container" )
4954 tree .add ("exit: Exit the shell" )
50- panel = Panel (tree , title = title , expand = False , border_style = "green " )
55+ panel = Panel (tree , title = title , expand = False , border_style = "purple " )
5156 console .print (panel )
57+
5258def run_hacker_command (cmd ):
5359 if cmd .strip () == "" :
5460 return
5561 if cmd == "exit" :
62+ console .print ("Exiting Hacker Shell..." , style = "gray" )
5663 sys .exit (0 )
64+ console .print (f"Executing: hacker { cmd } " , style = "purple" )
5765 try :
58- result = subprocess .run (["hacker" ] + cmd .split (), capture_output = True , text = True )
59- if result .returncode == 0 :
60- console .print (result .stdout , style = "green" )
66+ process = subprocess .Popen (["hacker" ] + cmd .split (), stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True )
67+ stdout , stderr = process .communicate ()
68+ if process .returncode == 0 :
69+ if stdout .strip ():
70+ console .print (stdout , style = "white" )
71+ else :
72+ console .print ("Command executed successfully (no output)." , style = "gray" )
6173 else :
62- console .print (result .stderr , style = "red" )
74+ console .print (stderr , style = "red" )
75+ console .print (f"Error: Command failed with exit code { process .returncode } " , style = "red" )
6376 except Exception as e :
6477 console .print (f"Error executing command: { e } " , style = "red" )
78+
6579def main ():
6680 session = PromptSession (completer = completer , style = style )
81+ console .print ("Welcome to Hacker Shell! Type 'exit' to quit." , style = "blue" )
6782 while True :
6883 display_command_list ()
6984 try :
70- cmd = session .prompt ('> ' )
85+ cmd = session .prompt ('hacker-shell > ' )
7186 run_hacker_command (cmd )
87+ console .input ("Press Enter to continue..." )
7288 except KeyboardInterrupt :
89+ console .print ("\n Interrupted. Type 'exit' to quit." , style = "gray" )
7390 continue
7491 except EOFError :
7592 break
93+
7694if __name__ == "__main__" :
7795 main ()
0 commit comments