From 9de7357d758ab2253061ce7d68fb3942b52ee7a3 Mon Sep 17 00:00:00 2001 From: zlg Date: Sat, 6 Oct 2018 22:04:53 -0700 Subject: cli: change "Status" heading to "Progress" --- src/vgstash_cli.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/vgstash_cli.py') diff --git a/src/vgstash_cli.py b/src/vgstash_cli.py index e4d1a32..5aada8c 100644 --- a/src/vgstash_cli.py +++ b/src/vgstash_cli.py @@ -28,24 +28,24 @@ def init(): else: raise sqlite3.OperationalError("Cannot create schema.") + def row_format(row, width, header): """ - TODO + Prints a row from the result set into a nice table. """ - # There's another way to do this, involving gathering the entire results and - # *then* formatting them. That is incredibly wasteful of resources imo, so - # it may need some testing to see if it's better. Ideally, we'd only make - # the table as wide as needed; that can't happen unless we know the longest - # title's length... - - twidth = int(width) - 35 + # The magic number comes from: + # game ID (4) + # system name (8) + # ownership (3) + # progress (9) + twidth = int(width) - 36 if header == True: - click.echo("{:^4s} | {:<{w}s} | {:<8s} | {:^3s} | {:<7s}".format( + click.echo("{:^4s} | {:<{w}s} | {:<8s} | {:^3s} | {:<9s}".format( "ID", "Title", "System", "Own", - "Status", + "Progress", w=twidth) ) click.echo("-" * int(width)) @@ -56,15 +56,16 @@ def row_format(row, width, header): # unowned, physical, digital, both ownltr = [' ', 'P', ' D', 'P D'] ownstr = "{: <3s}".format(ownltr[row['ownership']]) - statltr = { - -1: 'U', - 0: 'N', - 1: 'P', - 2: 'B', - 3: 'C' + progltr = { + 0: '', + 1: 'N', + 2: 'P', + 3: 'B', + 4: 'C' } - statstr = "{: <7s}".format((" " * row['progress'] * 2) + statltr[row['progress']]) - print(" | ".join((gidstr, titlestr, systemstr, ownstr, statstr))) + progstr = "{: <7s}".format((" " * row['progress'] * 2) + progltr[row['progress']]) + print(" | ".join((gidstr, titlestr, systemstr, ownstr, progstr))) + @cli.command('add') @click.argument('title', type=str) -- cgit v1.2.3-54-g00ecf