Basic card list tabulation

pull/2115/head
Kieran R. Prasch 2020-06-26 16:09:09 -07:00
parent e99674a3fd
commit 138850bd05
No known key found for this signature in database
GPG Key ID: FDC3146ED25617D8
2 changed files with 3 additions and 4 deletions

View File

@ -603,7 +603,7 @@ def contacts(general_config, list_contacts, create, card_id, delete, import_file
card_id, ext = filename.split('.')
card = Card.load(checksum=card_id)
cards.append(card)
paint_cards(emitter=emitter, cards=cards)
paint_cards(emitter=emitter, cards=cards, as_table=True)
return
elif create:

View File

@ -34,9 +34,8 @@ def paint_single_card(emitter, card: Card, qrcode: bool = False) -> None:
def paint_cards(emitter, cards: List[Card], as_table: bool = True) -> None:
if as_table:
headers = [field for field in Card._specification]
rows = [card.to_dict() for card in cards]
emitter.echo(tabulate(rows, headers=headers, showindex='always'))
rows = [card.to_json(as_string=False) for card in cards]
emitter.echo(tabulate(rows, headers='keys', showindex='always'))
else:
for card in cards:
paint_single_card(emitter=emitter, card=card)