Skip to content

Commit 7f80b0a

Browse files
committed
pretty print results of command list-folders and list-tags
1 parent f7d9196 commit 7f80b0a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

inoreader/main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import yaml
1818
import click
19+
from tabulate import tabulate
1920
from flask import Flask, request
2021
from requests_oauthlib import OAuth2Session
2122

@@ -153,18 +154,25 @@ def list_folders():
153154
"""List all folders"""
154155
client = get_client()
155156
res = client.get_folders()
156-
print("unread\tfolder")
157+
158+
output_info = [["Folder", "Unread Count"]]
157159
for item in res:
158-
print("{}\t{}".format(item['unread_count'], item['name']))
160+
output_info.append([item['name'], item['unread_count']])
161+
162+
print(tabulate(output_info, headers='firstrow', tablefmt="github"))
159163

160164

161165
@main.command("list-tags")
162166
def list_tags():
163167
"""List all tags"""
164168
client = get_client()
165169
res = client.get_tags()
170+
171+
output_info = [["Tag", "Unread Count"]]
166172
for item in res:
167-
print("{}\t{}".format(item['unread_count'], item['name']))
173+
output_info.append([item['name'], item['unread_count']])
174+
175+
print(tabulate(output_info, headers='firstrow', tablefmt="github"))
168176

169177

170178
@main.command("fetch-unread")

0 commit comments

Comments
 (0)