Skip to content

Commit 7e6e8a4

Browse files
authored
Code review with Gemini ; unify some cli interfaces ; fix album listing (#48)
* Generate plan for refactoring code and unifying subcommand interfaces for key entities * Align AGENTS.md with poe usage * feat: Unify CLI commands structure and implement missing commands * docs: Update CLI command documentation to match standardized interface * docs: Finalize CLI unification implementation log * feat: improve album listing and standardize default sort order - Collapse duplicate albums by title in 'albums list' for cleaner display - Remove 'artist' and 'tracks' columns from default album list view - Fix 'min-plays' filtering bug in album query logic - Change default sort order to 'recent' for all 'list' commands - Update documentation and tests to reflect these changes * Update cog generated docs * Fix QA errors: remove unused imports and update vulnerable dependencies * Set default limit to 20 for unified commands and update docs * Committing updated autogenerated documentation * Refactor stats command and update plays list default limit - Refactor 'stats' command to use shared options from 'command_utils'. - Add support for '-f' short option for '--format'. - Update default limit for 'plays list' from 20 to 50. - Add 'tests/test_plays_unify.py' to verify 'plays list' changes. Coauthored with Gemini CLI Danger! Danger! High Voltage!
1 parent a0323db commit 7e6e8a4

21 files changed

Lines changed: 1668 additions & 903 deletions

AGENTS.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ type checking.
1717
# set up environment from pyproject + uv.lock
1818
uv sync
1919

20+
# poe is Poe the Poet, a Python task runner
21+
# poe integrates well with pyproject.toml
22+
23+
# list tasks
24+
uv run poe
25+
2026
# run the test suite (quiet, stop on first failure)
21-
uv run pytest -q -x
27+
uv run poe test:quick
2228

2329
# run tests with coverage reporting
24-
uv run pytest --cov=./src/copyedit_ai --cov-report=html
30+
uv run poe test:cov
2531

2632
# run type checks & lint (if dev deps are present)
27-
uv run ty src/copyedit_ai
28-
uv run ruff check src tests
29-
uv run ruff format src tests
33+
uv run poe type
34+
uv run poe lint
35+
uv run poe lint:fix
3036

3137
# run the package (replace with your module/CLI)
32-
uv run python -m copyedit_ai --help
38+
uv run scrobbledb --help
3339

34-
# poe is Poe the Poet, a Python task runner
35-
# poe integrates well with pyproject.toml
36-
37-
# list tasks
38-
poe
3940
```

docs/commands/albums.md

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Commands:
2525
list List albums with optional artist filter.
2626
search Search for albums using fuzzy matching.
2727
show Display detailed information about a specific album and list its...
28+
top Show top albums with flexible time range support.
2829
```
2930
<!-- [[[end]]] -->
3031

@@ -57,11 +58,10 @@ Options:
5758
-d, --database FILE Database path (default: XDG data directory)
5859
-l, --limit INTEGER Maximum results [default: 20]
5960
--artist TEXT Filter by artist name
60-
--format [table|csv|json|jsonl]
61+
-f, --format [table|csv|json|jsonl]
6162
Output format [default: table]
62-
--fields TEXT Fields to include in output (comma-separated
63-
or repeated). Available: id, album, artist,
64-
tracks, plays, last_played
63+
--fields TEXT Fields to include. Available: id, album,
64+
artist, tracks, plays, last_played
6565
--select Interactive mode: select a single result and
6666
output its details as JSON
6767
--help Show this message and exit.
@@ -92,11 +92,99 @@ Usage: scrobbledb albums show [OPTIONS] [ALBUM_TITLE]
9292
# Use album ID scrobbledb albums show --album-id 42
9393
9494
Options:
95-
-d, --database FILE Database path (default: XDG data directory)
96-
--album-id TEXT Use album ID instead of title
97-
--artist TEXT Artist name (to disambiguate albums with same
98-
title)
99-
--format [table|json|jsonl] Output format [default: table]
100-
--help Show this message and exit.
95+
-d, --database FILE Database path (default: XDG data directory)
96+
--album-id TEXT Use album ID instead of title
97+
--artist TEXT Artist name (to disambiguate albums with same
98+
title)
99+
-f, --format [table|json|jsonl]
100+
Output format [default: table]
101+
--help Show this message and exit.
102+
```
103+
<!-- [[[end]]] -->
104+
105+
### `list`
106+
List albums with optional filtering and sorting.
107+
108+
<!-- [[[cog
109+
result = runner.invoke(cli, ["albums", "list", "--help"], prog_name='scrobbledb')
110+
cog.out("```\n" + result.output + "```")
111+
]]] -->
112+
```
113+
Usage: scrobbledb albums list [OPTIONS]
114+
115+
List albums with optional artist filter.
116+
117+
Browse albums in your collection with sorting options. Filter by artist name
118+
or artist ID to see all albums by a specific artist.
119+
120+
Examples:
121+
# List top 50 albums by play count
122+
scrobbledb albums list
123+
124+
# List albums by specific artist scrobbledb albums list --artist
125+
"Radiohead"
126+
127+
# List albums alphabetically scrobbledb albums list --sort name
128+
--order asc
129+
130+
# List recently played albums with tracks scrobbledb albums list
131+
--sort recent --expand
132+
133+
Options:
134+
-d, --database FILE Database path (default: XDG data directory)
135+
-l, --limit INTEGER Maximum results [default: 20]
136+
--artist TEXT Filter by artist name
137+
--artist-id TEXT Filter by artist ID
138+
--order [desc|asc] Sort order [default: desc]
139+
--sort [plays|name|recent] Sort by: plays, name, recent [default:
140+
recent]
141+
--min-plays INTEGER Show only albums with at least N plays
142+
[default: 0]
143+
--expand Show detailed view with tracks for each album
144+
-f, --format [table|csv|json|jsonl]
145+
Output format [default: table]
146+
--fields TEXT Fields to include. Available: id, album,
147+
artist, tracks, plays, last_played
148+
--help Show this message and exit.
149+
```
150+
<!-- [[[end]]] -->
151+
152+
### `top`
153+
Show top albums with flexible time range support.
154+
155+
<!-- [[[cog
156+
result = runner.invoke(cli, ["albums", "top", "--help"], prog_name='scrobbledb')
157+
cog.out("```\n" + result.output + "```")
158+
]]] -->
159+
```
160+
Usage: scrobbledb albums top [OPTIONS]
161+
162+
Show top albums with flexible time range support.
163+
164+
Discover your most played albums over various time periods.
165+
166+
Examples:
167+
# Top 10 albums all-time
168+
scrobbledb albums top
169+
170+
# Top 25 albums this month scrobbledb albums top --limit 25 --period
171+
month
172+
173+
# Top albums by specific artist scrobbledb albums top --artist
174+
"Radiohead"
175+
176+
Options:
177+
-d, --database FILE Database path (default: XDG data directory)
178+
-l, --limit INTEGER Maximum results [default: 20]
179+
--period [week|month|quarter|year|all-time]
180+
Predefined period
181+
-u, --until TEXT End date/time for analysis period
182+
-s, --since TEXT Start date/time for analysis period
183+
--artist TEXT Filter by artist name
184+
-f, --format [table|csv|json|jsonl]
185+
Output format [default: table]
186+
--fields TEXT Fields to include. Available: rank, album,
187+
artist, plays, percentage
188+
--help Show this message and exit.
101189
```
102190
<!-- [[[end]]] -->

docs/commands/artists.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,16 @@ Usage: scrobbledb artists list [OPTIONS]
5959
6060
Options:
6161
-d, --database FILE Database path (default: XDG data directory)
62-
-l, --limit INTEGER Maximum results [default: 50]
63-
--sort [plays|name|recent] Sort by: plays, name, or recent [default:
64-
plays]
62+
-l, --limit INTEGER Maximum results [default: 20]
6563
--order [desc|asc] Sort order [default: desc]
64+
--sort [plays|name|recent] Sort by: plays, name, recent [default:
65+
recent]
6666
--min-plays INTEGER Show only artists with at least N plays
6767
[default: 0]
68-
--format [table|csv|json|jsonl]
68+
-f, --format [table|csv|json|jsonl]
6969
Output format [default: table]
70-
--fields TEXT Fields to include in output (comma-separated
71-
or repeated). Available: id, artist, plays,
72-
tracks, albums, last_played
70+
--fields TEXT Fields to include in output. Available: id,
71+
artist, plays, tracks, albums, last_played
7372
--help Show this message and exit.
7473
```
7574
<!-- [[[end]]] -->
@@ -103,16 +102,15 @@ Usage: scrobbledb artists top [OPTIONS]
103102
104103
Options:
105104
-d, --database FILE Database path (default: XDG data directory)
106-
-l, --limit INTEGER Number of artists to show [default: 10]
107-
-s, --since TEXT Start date/time for analysis period
108-
-u, --until TEXT End date/time for analysis period
105+
-l, --limit INTEGER Maximum results [default: 20]
109106
--period [week|month|quarter|year|all-time]
110107
Predefined period
111-
--format [table|csv|json|jsonl]
108+
-u, --until TEXT End date/time for analysis period
109+
-s, --since TEXT Start date/time for analysis period
110+
-f, --format [table|csv|json|jsonl]
112111
Output format [default: table]
113-
--fields TEXT Fields to include in output (comma-separated
114-
or repeated). Available: rank, artist, plays,
115-
percentage, avg_per_day
112+
--fields TEXT Fields to include. Available: rank, artist,
113+
plays, percentage, avg_per_day
116114
--help Show this message and exit.
117115
```
118116
<!-- [[[end]]] -->
@@ -138,9 +136,10 @@ Usage: scrobbledb artists show [OPTIONS] [ARTIST_NAME]
138136
# Use artist ID scrobbledb artists show --artist-id 123
139137
140138
Options:
141-
-d, --database FILE Database path (default: XDG data directory)
142-
--artist-id TEXT Use artist ID instead of name
143-
--format [table|json|jsonl] Output format [default: table]
144-
--help Show this message and exit.
139+
-d, --database FILE Database path (default: XDG data directory)
140+
--artist-id TEXT Use artist ID instead of name
141+
-f, --format [table|json|jsonl]
142+
Output format [default: table]
143+
--help Show this message and exit.
145144
```
146145
<!-- [[[end]]] -->

docs/commands/plays.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ Usage: scrobbledb plays list [OPTIONS]
4343
View listening history chronologically with flexible filtering.
4444
4545
Examples:
46-
# List last 20 plays
46+
# List last 50 plays
4747
scrobbledb plays list
4848
49-
# List last 50 plays scrobbledb plays list --limit 50
50-
5149
# List plays in the last week scrobbledb plays list --since "7 days
5250
ago"
5351
@@ -61,22 +59,18 @@ Usage: scrobbledb plays list [OPTIONS]
6159
6260
Options:
6361
-d, --database FILE Database path (default: XDG data directory)
64-
-l, --limit INTEGER Maximum number of plays to return [default:
65-
20]
66-
-s, --since TEXT Show plays since date/time (ISO 8601 format or
67-
relative like "7 days ago")
68-
-u, --until TEXT Show plays until date/time (ISO 8601 format)
69-
--artist TEXT Filter by artist name (case-insensitive
70-
partial match)
71-
--album TEXT Filter by album title (case-insensitive
72-
partial match)
73-
--track TEXT Filter by track title (case-insensitive
74-
partial match)
75-
--format [table|csv|json|jsonl]
62+
-l, --limit INTEGER Maximum results [default: 50]
63+
--period [week|month|quarter|year|all-time]
64+
Predefined period
65+
-u, --until TEXT End date/time for analysis period
66+
-s, --since TEXT Start date/time for analysis period
67+
--artist TEXT Filter by artist name
68+
--album TEXT Filter by album title
69+
--track TEXT Filter by track title
70+
-f, --format [table|csv|json|jsonl]
7671
Output format [default: table]
77-
--fields TEXT Fields to include in output (comma-separated
78-
or repeated). Available: timestamp, artist,
79-
track, album
72+
--fields TEXT Fields to include in output. Available:
73+
timestamp, artist, track, album
8074
--help Show this message and exit.
8175
```
8276
<!-- [[[end]]] -->

docs/commands/stats.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ Usage: scrobbledb stats overview [OPTIONS]
6363
# Export to JSON scrobbledb stats overview --format json
6464
6565
Options:
66-
-d, --database TEXT Database path (default: XDG data dir)
67-
-f, --format [table|json|jsonl|csv]
68-
Output format (default: table)
66+
-d, --database FILE Database path (default: XDG data directory)
67+
-f, --format [table|csv|json|jsonl]
68+
Output format [default: table]
6969
--help Show this message and exit.
7070
```
7171
<!-- [[[end]]] -->
@@ -100,13 +100,14 @@ Usage: scrobbledb stats monthly [OPTIONS]
100100
monthly_stats.csv
101101
102102
Options:
103-
-d, --database TEXT Database path (default: XDG data dir)
104-
-s, --since TEXT Start date (ISO 8601 or relative like '7 days
105-
ago')
106-
-u, --until TEXT End date (ISO 8601 or relative)
107-
-l, --limit INTEGER Maximum number of months to display
108-
-f, --format [table|json|jsonl|csv]
109-
Output format (default: table)
103+
-d, --database FILE Database path (default: XDG data directory)
104+
--period [week|month|quarter|year|all-time]
105+
Predefined period
106+
-u, --until TEXT End date/time for analysis period
107+
-s, --since TEXT Start date/time for analysis period
108+
-l, --limit INTEGER Maximum results
109+
-f, --format [table|csv|json|jsonl]
110+
Output format [default: table]
110111
--help Show this message and exit.
111112
```
112113
<!-- [[[end]]] -->
@@ -138,13 +139,14 @@ Usage: scrobbledb stats yearly [OPTIONS]
138139
# Export to JSON scrobbledb stats yearly --format json
139140
140141
Options:
141-
-d, --database TEXT Database path (default: XDG data dir)
142-
-s, --since TEXT Start date (ISO 8601 or relative like '7 days
143-
ago')
144-
-u, --until TEXT End date (ISO 8601 or relative)
145-
-l, --limit INTEGER Maximum number of years to display
146-
-f, --format [table|json|jsonl|csv]
147-
Output format (default: table)
142+
-d, --database FILE Database path (default: XDG data directory)
143+
--period [week|month|quarter|year|all-time]
144+
Predefined period
145+
-u, --until TEXT End date/time for analysis period
146+
-s, --since TEXT Start date/time for analysis period
147+
-l, --limit INTEGER Maximum results
148+
-f, --format [table|csv|json|jsonl]
149+
Output format [default: table]
148150
--help Show this message and exit.
149151
```
150152
<!-- [[[end]]] -->

0 commit comments

Comments
 (0)