Skip to content

Commit 99fa16d

Browse files
committed
Improve progress bar for board scanning and update table styles in list.py
1 parent 4573340 commit 99fa16d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/mpflash/mpflash/list.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from .logger import console
1111

1212
rp_spinner = SpinnerColumn(finished_text="✅")
13-
rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column(ratio=1))
14-
rp_bar = BarColumn(bar_width=None, table_column=Column(ratio=2))
13+
rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
14+
rp_bar = BarColumn(bar_width=None, table_column=Column())
1515

1616

1717
def list_mcus(bluetooth: bool = False):
@@ -27,7 +27,7 @@ def list_mcus(bluetooth: bool = False):
2727

2828
# a lot of boilerplate to show a progress bar with the comport currenlty scanned
2929
with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn()) as progress:
30-
tsk_scan = progress.add_task("[red]Scanning", visible=False)
30+
tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
3131
progress.tasks[tsk_scan].fields["device"] = "..."
3232
progress.tasks[tsk_scan].visible = True
3333
progress.start_task(tsk_scan)
@@ -54,11 +54,10 @@ def show_mcus(
5454
"""Show the list of connected boards in a nice table"""
5555
table = Table(
5656
title=title,
57-
title_style="bold",
58-
header_style="bold blue",
57+
title_style="magenta",
58+
header_style="bold magenta",
5959
collapse_padding=True,
6060
width=110,
61-
row_styles=["blue", "yellow"],
6261
)
6362
table.add_column("Serial", overflow="fold")
6463
table.add_column("Family")
@@ -75,11 +74,12 @@ def show_mcus(
7574
mcu.get_mcu_info()
7675
except ConnectionError:
7776
continue
77+
description = f"[italic bright_cyan]{mcu.description}" if mcu.description else ""
7878
table.add_row(
7979
mcu.serialport.replace("/dev/", ""),
8080
mcu.family,
8181
mcu.port,
82-
f"{mcu.board}\n{mcu.description}".strip(),
82+
f"{mcu.board}\n{description}".strip(),
8383
# mcu.variant,
8484
mcu.cpu,
8585
mcu.version,

0 commit comments

Comments
 (0)