Skip to content

Commit c8d0c3d

Browse files
committed
add -all flag to analyze command
1 parent 37efe92 commit c8d0c3d

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

cli/main.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,51 +142,52 @@ def version():
142142
print(f"[red]{messages.get('error', 'Error:')}[/] {e}")
143143

144144

145-
# SPICE ANALYZE COMMAND
146145
@app.command()
147-
def analyze(file: str):
146+
def analyze(file: str, all: bool = typer.Option(False, "--all", help="Analyze all stats without selection menu")):
148147
"""
149148
Analyze the given file.
150149
"""
151150

152151
# load translations
153152
messages = get_translation()
154153

155-
# define available stats UPDATE THIS WHEN NEEDED PLEASE !!!!!!!!
154+
# define available stats UPDATE THIS WHEN NEEDED PLEASE !!!!!!!!
156155
available_stats = [
157156
"line_count",
158157
"function_count",
159158
"comment_line_count"
160159
]
161160

162-
# dicionary for the stats UPDATE THIS WHEN NEEDED PLEASE !!!!!!!!
161+
# dictionary for the stats UPDATE THIS WHEN NEEDED PLEASE !!!!!!!!
163162
stats_labels = {
164163
"line_count": messages.get("line_count_option", "Line Count"),
165164
"function_count": messages.get("function_count_option", "Function Count"),
166165
"comment_line_count": messages.get("comment_line_count_option", "Comment Line Count")
167166
}
168167

168+
# If --all flag is used, skip the selection menu and use all stats
169+
if all:
170+
selected_stat_keys = available_stats
171+
else:
172+
# print checkbox menu to select which stats to show
173+
selected_stats = inquirer.checkbox(
174+
message=messages.get("select_stats", "Select stats to display:"),
175+
choices=[stats_labels[stat] for stat in available_stats],
176+
pointer="> ",
177+
default=[stats_labels[stat] for stat in available_stats], # All selected by default
178+
instruction=messages.get("checkbox_hint", "(Use space to select, enter to confirm)")
179+
).execute()
180+
181+
# if no stats were selected
182+
if not selected_stats:
183+
print(messages.get("no_stats_selected", "No stats selected. Analysis cancelled."))
184+
return
169185

170-
# print checkbox menu to select which stats to show
171-
selected_stats = inquirer.checkbox(
172-
message=messages.get("select_stats", "Select stats to display:"),
173-
choices=[stats_labels[stat] for stat in available_stats],
174-
pointer="> ",
175-
default=[stats_labels[stat] for stat in available_stats], # All selected by default
176-
instruction=messages.get("checkbox_hint", "(Use space to select, enter to confirm)")
177-
).execute()
178-
179-
180-
# if no stats were selected
181-
if not selected_stats:
182-
print(messages.get("no_stats_selected", "No stats selected. Analysis cancelled."))
183-
return
184-
185-
# create a mapping from displayed labels back to stat keys
186-
reverse_mapping = {v: k for k, v in stats_labels.items()}
187-
188-
# convert selected labels back to stat keys
189-
selected_stat_keys = [reverse_mapping[label] for label in selected_stats]
186+
# create a mapping from displayed labels back to stat keys
187+
reverse_mapping = {v: k for k, v in stats_labels.items()}
188+
189+
# convert selected labels back to stat keys
190+
selected_stat_keys = [reverse_mapping[label] for label in selected_stats]
190191

191192
# try to analyze and if error then print the error
192193
try:

0 commit comments

Comments
 (0)