Skip to content

Commit eb480ed

Browse files
author
rakhim
committed
CLI WIP
1 parent 4bd8212 commit eb480ed

19 files changed

+1507
-0
lines changed

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ classifiers = [
2323

2424
dependencies = ["requests>=2.25.1,<3", "dataclasses_json>=0.6.7"]
2525

26+
[project.optional-dependencies]
27+
cli = [
28+
"typer>=0.12.0,<1",
29+
"rich>=13.0.0,<14",
30+
]
31+
32+
[project.scripts]
33+
verda-cli = "verda.cli.main:app"
34+
2635
[dependency-groups]
2736
dev = [
2837
"pytest-cov>=2.10.1,<3",

uv.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

verda/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Verda CLI module."""

verda/cli/commands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""CLI command modules."""

verda/cli/commands/balance.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Commands for checking account balance."""
2+
3+
import typer
4+
5+
from verda.cli import main as cli_main
6+
from verda.cli.utils.client import get_client
7+
from verda.cli.utils.errors import handle_api_errors
8+
from verda.cli.utils.output import console, output_json
9+
10+
app = typer.Typer(no_args_is_help=True)
11+
12+
13+
@app.command('get')
14+
@handle_api_errors
15+
def get_balance() -> None:
16+
"""Get account balance."""
17+
client = get_client()
18+
balance = client.balance.get()
19+
20+
if cli_main.state['json_output']:
21+
output_json({'amount': balance.amount, 'currency': balance.currency})
22+
else:
23+
console.print(f'Balance: [bold green]{balance.currency} {balance.amount:.2f}[/bold green]')

0 commit comments

Comments
 (0)