Skip to content

Commit 80ae265

Browse files
committed
feat: using PrettyTable to print data in table format
1 parent 8491e39 commit 80ae265

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
click == 8.0.4 # library to create CLI
22
requests == 2.27.1
33
configparser >= 5.2.0
4+
prettytable >= 3.3.0

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ install_requires =
2929
click == 8.0.4
3030
requests == 2.27.1
3131
configparser >= 5.2.0
32+
prettytable >= 3.3.0
3233
python_requires = >=3.7
3334
cmdclass =
3435
install = post_install.Install

src/list/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import click
22
from src.api.aitomatic import AiCloudApi
33
from src.login.main import authenticated
4+
from prettytable import PrettyTable
45

56

67
@click.command()
@@ -18,8 +19,9 @@ def list(obj, app_name: str, n: int) -> None:
1819

1920
jobs = data['data']
2021
if len(jobs) > 0:
21-
click.secho('ID Status Created at', fg='green')
22+
table = PrettyTable(['ID', 'Status', 'Created at'])
2223
for job in jobs:
23-
click.echo(f"{job['id']} {job['status']} {job['createdAt']}")
24+
table.add_row([job['id'], job['status'], job['createdAt']])
25+
click.echo(table)
2426
else:
2527
click.echo('This app has no job')

0 commit comments

Comments
 (0)