summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2018-10-06 22:04:53 -0700
committerzlg <zlg@zlg.space>2018-10-06 22:04:53 -0700
commit9de7357d758ab2253061ce7d68fb3942b52ee7a3 (patch)
treee227d7d71b7a7bd04d1698db0e5117f5edb73dd9 /src
parentBump to 0.3alpha5 for PyPI (diff)
downloadvgstash-9de7357d758ab2253061ce7d68fb3942b52ee7a3.tar.gz
vgstash-9de7357d758ab2253061ce7d68fb3942b52ee7a3.tar.bz2
vgstash-9de7357d758ab2253061ce7d68fb3942b52ee7a3.tar.xz
vgstash-9de7357d758ab2253061ce7d68fb3942b52ee7a3.zip
cli: change "Status" heading to "Progress"
Diffstat (limited to '')
-rw-r--r--src/vgstash/test_vgstash_cli.py39
-rw-r--r--src/vgstash_cli.py37
2 files changed, 40 insertions, 36 deletions
diff --git a/src/vgstash/test_vgstash_cli.py b/src/vgstash/test_vgstash_cli.py
index d0def8b..7306a7d 100644
--- a/src/vgstash/test_vgstash_cli.py
+++ b/src/vgstash/test_vgstash_cli.py
@@ -83,49 +83,52 @@ def test_list_filter():
))
def test_list_pretty():
+ print()
runner = CliRunner()
result = runner.invoke(vgstash_cli.cli, ['list', '-w', '80'])
if verbose:
print(result.output)
assert result.exit_code == 0
assert result.output == '\n'.join((
- ' ID | Title | System | Own | Status ',
+ ' ID | Title | System | Own | Progress ',
'--------------------------------------------------------------------------------',
- ' 3 | Sonic the Hedgehog 2 | Genesis | | C',
- ' 4 | Vectorman | Genesis | | C',
- ' 5 | Vectorman 2 | Genesis | P | B ',
- ' 1 | Super Mario Bros. | NES | P | B ',
- ' 2 | The Legend of Zelda | NES | D | B \n'
+ ' 3 | Sonic the Hedgehog 2 | Genesis | | B',
+ ' 4 | Vectorman | Genesis | | B',
+ ' 5 | Vectorman 2 | Genesis | P | P ',
+ ' 1 | Super Mario Bros. | NES | P | P ',
+ ' 2 | The Legend of Zelda | NES | D | P \n',
))
def test_list_pretty_smaller():
+ print()
runner = CliRunner()
result = runner.invoke(vgstash_cli.cli, ['list', '-w', '60'])
if verbose:
print(result.output)
assert result.exit_code == 0
assert result.output == '\n'.join((
- ' ID | Title | System | Own | Status ',
+ ' ID | Title | System | Own | Progress ',
'------------------------------------------------------------',
- ' 3 | Sonic the Hedgehog 2 | Genesis | | C',
- ' 4 | Vectorman | Genesis | | C',
- ' 5 | Vectorman 2 | Genesis | P | B ',
- ' 1 | Super Mario Bros. | NES | P | B ',
- ' 2 | The Legend of Zelda | NES | D | B \n'
+ ' 3 | Sonic the Hedgehog 2 | Genesis | | B',
+ ' 4 | Vectorman | Genesis | | B',
+ ' 5 | Vectorman 2 | Genesis | P | P ',
+ ' 1 | Super Mario Bros. | NES | P | P ',
+ ' 2 | The Legend of Zelda | NES | D | P \n'
))
def test_list_pretty_tiny():
+ print()
runner = CliRunner()
result = runner.invoke(vgstash_cli.cli, ['list', '-w', '50'])
if verbose:
print(result.output)
assert result.exit_code == 0
assert result.output == '\n'.join((
- ' ID | Title | System | Own | Status ',
+ ' ID | Title | System | Own | Progress ',
'--------------------------------------------------',
- ' 3 | Sonic the Hedge | Genesis | | C',
- ' 4 | Vectorman | Genesis | | C',
- ' 5 | Vectorman 2 | Genesis | P | B ',
- ' 1 | Super Mario Bro | NES | P | B ',
- ' 2 | The Legend of Z | NES | D | B \n'
+ ' 3 | Sonic the Hedg | Genesis | | B',
+ ' 4 | Vectorman | Genesis | | B',
+ ' 5 | Vectorman 2 | Genesis | P | P ',
+ ' 1 | Super Mario Br | NES | P | P ',
+ ' 2 | The Legend of | NES | D | P \n'
))
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)
owing it. 2018-09-08Add remaining filters to vgstash packagezlg1-2/+11 2018-09-04Update LICENSE to match setup.pyzlg1-80/+67 Whoops. 2018-09-03Branch off from master with pytest, tox, clickzlg16-778/+779 This commit is huge, but contains everything needed for a "proper" build system built on pytest + tox and a CLI built with click. For now, this branch will contain all new vgstash development activity until it reaches feature parity with master. The CLI is installed to pip's PATH. Only the 'init', 'add', and 'list' commands work, with only two filters. This is pre-alpha software, and is therefore not stable yet. 2018-03-18Flesh out filter types and ownership statuszlg3-82/+144 It's time for a refactor to a module; the functionality and interface are clashing. 2018-03-18README.mdown: break line correctlyzlg1-1/+1 2018-03-18add 'playlog' list filterzlg2-2/+9 This filter is used to get an idea of which games you're currently playing through, so you can prioritize games to play when you're bored and detect it when you've beaten a game but haven't marked it as such. 2018-03-13Update helpers a bitzlg1-2/+9 At present, user modification is needed to make these seamless. vgup() may need to be axed in favor of telling the user to make an alias. 2018-03-13Make VGSTASH_DB_LOCATION point to a filezlg2-21/+20 It used to point to a directory, which would then look for .vgstash.db. This behavior was kind of backwards and I don't remember why I did it that way. This change gives users more control over where they put their DB. Be sure to update your environment variable if you have it set! 2016-11-18Remove settings from helpers.shZe Libertine Gamer1-5/+0 Sourcing them in .bash_profile screws up login if they're set. 2016-11-15Correct phrasing in README.Ze Libertine Gamer1-4/+4 2016-11-13DerpZe Libertine Gamer1-0/+1 2016-11-03Improve error handling in shell scriptsZe Libertine Gamer4-3/+23 2016-10-24Correct run_again, add recursionZe Libertine Gamer1-0/+4 Loops and functions -- oh my, what a useful combination. :) 2016-10-21Add quotes to correct behavior for arglistZe Libertine Gamer1-1/+1 2016-10-14updater.sh: add recursion, error handlingZe Libertine Gamer1-43/+101 2016-10-14Correct pipe-handling behaviorZe Libertine Gamer1-1/+9 2016-10-12Clarify a method to move between platformsZe Libertine Gamer1-2/+5 Also correct a typo.