1+ import os
2+ import sys
3+ import typer
4+
5+ # this is the analyzer
6+ from spice .analyze import analyze_file
7+
8+ # here we import utilities
9+ from cli .utils .get_translation import get_translation
10+
11+ # here we import the commands
12+ from cli .commands .translate import translate_command
13+ from cli .commands .hello import hello_command
14+ from cli .commands .version import version_command
15+ from cli .commands .analyze import analyze_command
16+
17+
18+ # initialize typer
19+ app = typer .Typer ()
20+
21+ # add the current directory (cli) to the sys.path
22+ sys .path .append ('cli' )
23+
24+ # get current directory, this is needed for it to work on other peoples computers via pip
25+ CURRENT_DIR = os .path .dirname (os .path .abspath (__file__ ))
26+
27+ # select a file to save the current selected langague (if saved to memory it wont persist between commands)
28+ LANG_FILE = os .path .join (CURRENT_DIR , "lang.txt" )
29+
30+
31+
32+ # SPICE TRANSLATE COMMAND
33+ @app .command ()
34+ def translate ():
35+ """
36+ Set the language for CLI messages.
37+ """
38+
39+ translate_command (LANG_FILE )
40+
41+ # -- end -- #
42+
43+
44+ # SPICE HELLO COMMAND
45+ @app .command ()
46+ def hello ():
47+ """
48+ Welcome message.
49+ """
50+
51+ hello_command (LANG_FILE )
52+
53+ # -- end -- #
54+
55+
56+ # SPICE VERSION COMMAND
57+ @app .command ()
58+ def version ():
59+ """
60+ Display the current version of the application.
61+ """
62+
63+ version_command (LANG_FILE , CURRENT_DIR )
64+
65+ #--- end ---#
66+
67+
68+ # SPICE ANALYZE COMMAND
69+ @app .command ()
70+ def analyze (
71+ file : str ,
72+ all : bool = typer .Option (False , "--all" , help = "Analyze all stats without selection menu" ),
73+ json_output : bool = typer .Option (False , "--json" , help = "Output results in JSON format" )
74+ ):
75+ """
76+ Analyze the given file.
77+ """
78+
79+ analyze_command (file , all , json_output , LANG_FILE )
80+
81+ # -- end -- #
82+
83+
84+ def main ():
85+ app () # run typer
86+
87+ # -- end -- #
88+
89+
90+ # whatever the fuck this is python makes no sense
91+ if __name__ == "__main__" :
92+ main ()
93+
94+ # -- end -- #
0 commit comments