From 6df227e7e61dddab41c574f0cab17d39bc7a5a5d Mon Sep 17 00:00:00 2001 From: Lulzette Date: Thu, 7 Apr 2022 16:08:28 +0300 Subject: [PATCH] replace ugly tables with PrettyTables --- twvdscli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/twvdscli.py b/twvdscli.py index d94b415..fcfcefd 100755 --- a/twvdscli.py +++ b/twvdscli.py @@ -8,7 +8,7 @@ import typer import os import configparser import base64 -import prettytable +from prettytable import PrettyTable app = typer.Typer() servers_app = typer.Typer() @@ -59,9 +59,11 @@ def get_balance(): print(typer.style("Error", fg=typer.colors.RED)) sys.exit(1) else: + x = PrettyTable() + x.field_names = ["Balance", "Monthly cost"] response = response.json() - print('{0:6} {1:}'.format('balance', 'monthly_cost')) - print('{0:6} {1:}'.format(response['finances']['balance'], response['finances']['monthly_cost'])) + x.add_row([response['finances']['balance'], response['finances']['monthly_cost']]) + print(x) @servers_app.command("start")