Skip to content

Commit e4d677f

Browse files
committed
refactor(file_toolkit): enhance progress display and streamline main menu logic
1 parent 2c5514b commit e4d677f

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

bugscanx/modules/others/file_toolkit.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from rich import print
99
from rich.panel import Panel
1010
from rich.padding import Padding
11-
from rich.progress import Progress, SpinnerColumn, TimeElapsedColumn
12-
13-
from bugscanx.utils.common import get_input, get_confirm
11+
from rich.progress import Progress, TimeElapsedColumn
1412

13+
from bugscanx.utils.common import get_input, get_confirm, clear_screen
14+
from bugscanx import text_ascii
1515

1616
def read_lines(file_path):
1717
try:
@@ -226,9 +226,9 @@ def domains_to_ip():
226226
socket.setdefaulttimeout(1)
227227

228228
with Progress(
229-
SpinnerColumn(), *Progress.get_default_columns(), TimeElapsedColumn()
229+
*Progress.get_default_columns(), TimeElapsedColumn(), transient=True
230230
) as progress:
231-
task = progress.add_task("[yellow]Resolving", total=len(domains))
231+
task = progress.add_task("[yellow] Resolving", total=len(domains))
232232

233233
with ThreadPoolExecutor(max_workers=100) as executor:
234234
def resolve_domain(domain):
@@ -273,29 +273,36 @@ def main():
273273
"6": ("FILTER BY KEYWORD", filter_by_keywords, "bold yellow"),
274274
"7": ("CIDR TO IP", cidr_to_ip, "bold green"),
275275
"8": ("DOMAIN TO IP", domains_to_ip, "bold blue"),
276-
"0": ("BACK", lambda: None, "bold red")
276+
"0": ("BACK", lambda: None, "bold red"),
277277
}
278-
278+
279279
while True:
280280
print("\n".join(
281281
f"[{color}] [{key}] {desc}" for key, (desc, _, color) in options.items()
282282
))
283+
283284
choice = input("\n\033[36m [-] Your Choice: \033[0m").strip()
284285

285286
if choice == '0':
286287
raise KeyboardInterrupt
287-
288-
if choice not in options:
289-
from bugscanx import text_ascii
288+
289+
action = options.get(choice)
290+
if not action:
290291
text_ascii("FILE TOOLKIT")
291292
continue
292-
293-
if choice in options:
294-
print()
293+
294+
desc, func, color = action
295+
296+
try:
297+
clear_screen()
295298
print(Padding(Panel.fit(
296-
f"[{options[choice][2]}]{options[choice][0]}[/{options[choice][2]}]",
297-
border_style=options[choice][2]
298-
), (0, 0, 0, 2)))
299-
print()
300-
options[choice][1]()
301-
break
299+
f"[{color}]{desc}[/{color}]",
300+
border_style=color
301+
), (0, 0, 1, 2)))
302+
func()
303+
print("\n[yellow] Press Enter to continue...", end="")
304+
input()
305+
except KeyboardInterrupt:
306+
pass
307+
finally:
308+
text_ascii("FILE TOOLKIT")

0 commit comments

Comments
 (0)