Skip to content

Commit 334e888

Browse files
feat: use rich instead of typer.secho (#865)
1 parent db3918d commit 334e888

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/cli/app/commands/download.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
from urllib.parse import urlparse
55

66
import async_typer as typer
7+
from rich.console import Console
78

89
from app import client
910
from app.builder.urls import UrlBuilder
1011
from app.helpers.archive import decompress
1112
from app.helpers.crypto import base64url_to_ikm, decrypt
1213

1314
app = typer.AsyncTyper(help="Download encrypted files via Chithi.")
15+
console: Console = Console()
16+
error_console: Console = Console(stderr=True)
1417

1518

1619
@app.async_command()
@@ -62,8 +65,8 @@ async def download(
6265
out_path = output.resolve()
6366
decompress(tmp_zip, out_path, password=password)
6467

65-
typer.secho(f"\n✓ Success! Extracted to {out_path}", fg=typer.colors.GREEN)
68+
console.print(f"\n[green]✓ Success! Extracted to {out_path}[/green]")
6669

6770
except Exception as exc:
68-
typer.secho(f"✗ Download failed: {exc}", fg=typer.colors.RED, err=True)
71+
error_console.print(f"[red]✗ Download failed: {exc}[/red]")
6972
raise typer.Exit(1)

src/cli/app/commands/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from app.helpers.print import print_compact_qr
1515

1616
app = typer.AsyncTyper(help="Upload encrypted files via Chithi.")
17-
console: Console = Console()
17+
console = Console()
1818

1919

2020
@app.async_command()

0 commit comments

Comments
 (0)