diff options
Diffstat (limited to '')
| -rwxr-xr-x | src/vgstash/__init__.py | 24 | ||||
| -rw-r--r-- | src/vgstash/test_vgstash_cli.py | 52 | ||||
| -rw-r--r-- | src/vgstash_cli.py | 8 | 
3 files changed, 46 insertions, 38 deletions
diff --git a/src/vgstash/__init__.py b/src/vgstash/__init__.py index 798a062..71b5981 100755 --- a/src/vgstash/__init__.py +++ b/src/vgstash/__init__.py @@ -33,18 +33,18 @@ DEFAULT_CONFIG = {  }  FILTERS = { -    'allgames': "SELECT rowid,* FROM games ORDER BY system, title", -    'backlog':  "SELECT rowid,* FROM games WHERE ownership > 0 AND progress < 3 ORDER BY system, title ASC", -    'borrowing': "SELECT rowid,* FROM games WHERE ownership = 0 AND progress = 2 ORDER BY system, title ASC", -    'complete': "SELECT rowid,* FROM games WHERE progress = 4 ORDER BY system, title ASC", -    'digital': "SELECT rowid,* FROM games WHERE ownership = 2 ORDER BY system, title ASC", -    'done': "SELECT rowid,* FROM games WHERE progress > 2 ORDER BY system, title ASC", -    'incomplete': "SELECT rowid,* FROM games WHERE progress = 3 AND ownership > 0 ORDER BY system, title ASC", -    'new': "SELECT rowid,* FROM games WHERE progress = 1 ORDER BY system, title ASC", -    'owned': "SELECT rowid,* FROM games WHERE ownership > 0 ORDER BY system, title ASC", -    'physical': "SELECT rowid,* FROM games WHERE ownership = 1 ORDER BY system, title ASC", -    'playlog': "SELECT rowid,* FROM games WHERE ownership > 0 AND progress = 2 ORDER BY system, title ASC", -    'unowned': "SELECT rowid,* FROM games WHERE ownership = 0 ORDER BY system, title ASC", +    'allgames': "SELECT * FROM games ORDER BY system, title", +    'backlog':  "SELECT * FROM games WHERE ownership > 0 AND progress < 3 ORDER BY system, title ASC", +    'borrowing': "SELECT * FROM games WHERE ownership = 0 AND progress = 2 ORDER BY system, title ASC", +    'complete': "SELECT * FROM games WHERE progress = 4 ORDER BY system, title ASC", +    'digital': "SELECT * FROM games WHERE ownership = 2 ORDER BY system, title ASC", +    'done': "SELECT * FROM games WHERE progress > 2 ORDER BY system, title ASC", +    'incomplete': "SELECT * FROM games WHERE progress = 3 AND ownership > 0 ORDER BY system, title ASC", +    'new': "SELECT * FROM games WHERE progress = 1 ORDER BY system, title ASC", +    'owned': "SELECT * FROM games WHERE ownership > 0 ORDER BY system, title ASC", +    'physical': "SELECT * FROM games WHERE ownership = 1 ORDER BY system, title ASC", +    'playlog': "SELECT * FROM games WHERE ownership > 0 AND progress = 2 ORDER BY system, title ASC", +    'unowned': "SELECT * FROM games WHERE ownership = 0 ORDER BY system, title ASC",  }  def kvmatch(arg, dict_map, fallback): diff --git a/src/vgstash/test_vgstash_cli.py b/src/vgstash/test_vgstash_cli.py index 7306a7d..faf87b2 100644 --- a/src/vgstash/test_vgstash_cli.py +++ b/src/vgstash/test_vgstash_cli.py @@ -16,6 +16,7 @@ def test_init():      assert result.exit_code == 0      assert result.output == "Initializing the database...\nSchema created.\n" +  def test_add_minimum():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['add', 'Super Mario Bros.', 'NES']) @@ -24,6 +25,7 @@ def test_add_minimum():      assert result.exit_code == 0      assert result.output == "Added Super Mario Bros. for NES. You physically own it and are playing it.\n" +  def test_add_ownership():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['add', 'The Legend of Zelda', 'NES', 'd']) @@ -32,6 +34,7 @@ def test_add_ownership():      assert result.exit_code == 0      assert result.output == "Added The Legend of Zelda for NES. You digitally own it and are playing it.\n" +  def test_add_typical():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['add', 'Sonic the Hedgehog 2', 'Genesis', '0', '3']) @@ -40,6 +43,7 @@ def test_add_typical():      assert result.exit_code == 0      assert result.output == "Added Sonic the Hedgehog 2 for Genesis. You do not own it and have beaten it.\n" +  def test_add_full():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['add', 'Vectorman', 'Genesis', 'u', 'b', 'beep']) @@ -48,6 +52,7 @@ def test_add_full():      assert result.exit_code == 0      assert result.output == "Added Vectorman for Genesis. You do not own it and have beaten it. It also has notes.\n" +  def test_add_full_note_with_newline():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['add', 'Vectorman 2', 'Genesis', 'p', 'p', 'beep\nboop']) @@ -56,6 +61,7 @@ def test_add_full_note_with_newline():      assert result.exit_code == 0      assert result.output == "Added Vectorman 2 for Genesis. You physically own it and are playing it. It also has notes.\n" +  def test_list():      runner = CliRunner()      result = runner.invoke(vgstash_cli.list_games, ['--raw']) @@ -70,6 +76,7 @@ def test_list():          'The Legend of Zelda|NES|2|2|\n',      )) +  def test_list_filter():      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['list', '-r', 'playlog']) @@ -82,53 +89,56 @@ def test_list_filter():          'The Legend of Zelda|NES|2|2|\n',      )) +  def test_list_pretty(): -    print()      runner = CliRunner()      result = runner.invoke(vgstash_cli.cli, ['list', '-w', '80'])      if verbose: +        print()          print(result.output)      assert result.exit_code == 0      assert result.output == '\n'.join(( -        ' ID  | Title                                        | System   | Own | Progress ', +        'Title                                               | System   | Own | Progress ',          '--------------------------------------------------------------------------------', -        '   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', +        'Sonic the Hedgehog 2                                | Genesis  |     |       B', +        'Vectorman                                           | Genesis  |     |       B', +        'Vectorman 2                                         | Genesis  | P   |     P  ', +        'Super Mario Bros.                                   |   NES    | P   |     P  ', +        '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()          print(result.output)      assert result.exit_code == 0      assert result.output == '\n'.join(( -        ' ID  | Title                    | System   | Own | Progress ', +        'Title                           | System   | Own | Progress ',          '------------------------------------------------------------', -        '   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' +        'Sonic the Hedgehog 2            | Genesis  |     |       B', +        'Vectorman                       | Genesis  |     |       B', +        'Vectorman 2                     | Genesis  | P   |     P  ', +        'Super Mario Bros.               |   NES    | P   |     P  ', +        '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()          print(result.output)      assert result.exit_code == 0      assert result.output == '\n'.join(( -        ' ID  | Title          | System   | Own | Progress ', +        'Title                 | System   | Own | Progress ',          '--------------------------------------------------', -        '   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' +        'Sonic the Hedgehog 2  | Genesis  |     |       B', +        'Vectorman             | Genesis  |     |       B', +        'Vectorman 2           | Genesis  | P   |     P  ', +        'Super Mario Bros.     |   NES    | P   |     P  ', +        'The Legend of Zelda   |   NES    |   D |     P  \n'      )) diff --git a/src/vgstash_cli.py b/src/vgstash_cli.py index 5aada8c..39d2454 100644 --- a/src/vgstash_cli.py +++ b/src/vgstash_cli.py @@ -38,10 +38,9 @@ def row_format(row, width, header):      #    system name (8)      #    ownership (3)      #    progress (9) -    twidth = int(width) - 36 +    twidth = int(width) - 29      if header == True: -        click.echo("{:^4s} | {:<{w}s} | {:<8s} | {:^3s} | {:<9s}".format( -            "ID", +        click.echo("{:<{w}s} | {:<8s} | {:^3s} | {:<9s}".format(              "Title",              "System",              "Own", @@ -50,7 +49,6 @@ def row_format(row, width, header):          )          click.echo("-" * int(width)) -    gidstr = "{: >4d}".format(row['rowid'])      titlestr = "{: <{w}s}".format(row['title'][:twidth], w=twidth)      systemstr = "{: ^8s}".format(row['system'][:8])      # unowned, physical, digital, both @@ -64,7 +62,7 @@ def row_format(row, width, header):          4: 'C'      }      progstr = "{: <7s}".format((" " * row['progress'] * 2) + progltr[row['progress']]) -    print(" | ".join((gidstr, titlestr, systemstr, ownstr, progstr))) +    print(" | ".join((titlestr, systemstr, ownstr, progstr)))  @cli.command('add')  | 
