Skip to content

Commit 273d947

Browse files
committed
refactor: Enhance run_option function to support menu context for better flow control
1 parent c06c396 commit 273d947

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bugscanx/main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def display_menu():
2424
print("\n".join(f"[{color}] [{k}]{' ' if len(k)==1 else ''} {desc}"
2525
for k, (desc, color) in MENU_OPTIONS.items()))
2626

27-
def run_option(choice):
27+
def run_option(choice, from_menu=True):
2828
if choice == '12':
2929
return False
3030
if choice not in MENU_OPTIONS:
@@ -35,7 +35,9 @@ def run_option(choice):
3535

3636
try:
3737
getattr(import_module('bugscanx.entrypoints.runner'), f'run_{choice}')()
38-
print("\n[yellow] Press Enter to continue...", end="")
38+
if from_menu:
39+
print("\n[yellow] Press Enter to continue...", end="")
40+
input()
3941
except KeyboardInterrupt:
4042
print("\n[yellow] Operation cancelled by user.")
4143
return True
@@ -51,14 +53,14 @@ def main():
5153
print(f"[bold cyan]BugScanX version {metadata.version('bugscan-x')}[/bold cyan]")
5254
return
5355
if args.update:
54-
return run_option('11')
56+
return run_option('11', from_menu=False)
5557
if args.option:
56-
return 0 if run_option(args.option) else 1
58+
return 0 if run_option(args.option, from_menu=False) else 1
5759

5860
try:
5961
while True:
6062
display_menu()
61-
if not run_option(input("\n\033[36m [-] Your Choice: \033[0m")):
63+
if not run_option(input("\n\033[36m [-] Your Choice: \033[0m"), from_menu=True):
6264
break
6365
except KeyboardInterrupt:
6466
sys.exit(0)

0 commit comments

Comments
 (0)