Skip to content

Add comprehensive CLI commands to mirror Krónan Public API#4

Merged
arnif merged 3 commits into
mainfrom
add-comprehensive-commands
Apr 9, 2026
Merged

Add comprehensive CLI commands to mirror Krónan Public API#4
arnif merged 3 commits into
mainfrom
add-comprehensive-commands

Conversation

@arnif

@arnif arnif commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds comprehensive CLI commands to fully mirror the Krónan Public API, building on the previous API migration.

New Commands Added

📁 Categories

Browse products by category hierarchy:

kronan categories                    # List all categories
kronan category <slug> [--page N]    # Browse products by category

📝 Order Modifications

Modify active orders before they're fulfilled:

kronan order delete-lines <token> <lineId1> [lineId2...]
kronan order lower-quantity <token> <lineIds...> --quantity N
kronan order toggle-substitution <token> <lineIds...>

📋 Product Lists (Full CRUD)

Manage saved product collections:

kronan lists create <name> [--description "..."]
kronan lists view <token>
kronan lists delete <token> [--force]
kronan lists add <list-token> <sku> [qty]
kronan lists remove <list-token> <sku>
kronan lists clear <token> [--force]

✅ Shopping Notes (Skundalisti)

Manage freeform shopping lists for Scan and Go:

kronan notes                                    # View shopping note
kronan notes add [--text "..."] [--sku SKU] [--quantity N]
kronan notes update <line-token> [--text "..."] [--quantity N]
kronan notes remove <line-token>
kronan notes toggle <line-token>               # Mark complete/incomplete
kronan notes clear [--force]
kronan notes archived                          # View completed items

📊 Purchase Statistics

View purchase history and frequency data:

kronan stats [--limit N] [--offset N] [--include-ignored]
kronan stats ignore <id>
kronan stats unignore <id>

New Files

  • src/commands/categories.ts - Category browsing
  • src/commands/orders-modify.ts - Order modifications
  • src/commands/product-lists.ts - Full product list CRUD
  • src/commands/shopping-notes.ts - Shopping notes management
  • src/commands/purchase-stats.ts - Purchase statistics

Bug Fixes

  • Fixed getMe() to handle both object and array responses from API
  • Fixed getShoppingNote() to handle both object and array responses
  • Fixed stats command to properly handle flags when no subcommand given

API Coverage

Feature Status
✅ Me View identity
✅ Products Search, details
✅ Categories List, browse by category
✅ Orders List, details, delete lines, lower quantity, toggle substitution
✅ Checkout View, add lines, clear
✅ Product Lists Full CRUD + item management
✅ Shopping Notes Full CRUD + archived items
✅ Purchase Stats View, ignore/unignore

Testing

All commands tested and working:

  • ✅ Lint passes
  • ✅ TypeScript typecheck passes
  • ✅ 13 tests passing
  • ✅ All new commands functional

The CLI now comprehensively covers all functionality available in the Krónan Public API.

arnif added 3 commits April 9, 2026 18:48
New commands added:

CATEGORIES:
- kronan categories              List all categories with hierarchy
- kronan category <slug>         Browse products by category

ORDER MODIFICATIONS:
- kronan order delete-lines <token> <lineIds...>
- kronan order lower-quantity <token> <lineIds...> --quantity N
- kronan order toggle-substitution <token> <lineIds...>

PRODUCT LISTS (full CRUD):
- kronan lists create <name> [--description ...]
- kronan lists view <token>
- kronan lists delete <token> [--force]
- kronan lists add <list-token> <sku> [qty]
- kronan lists remove <list-token> <sku>
- kronan lists clear <token> [--force]

SHOPPING NOTES (Skundalisti):
- kronan notes                   View shopping note
- kronan notes add [--text ...] [--sku SKU] [--quantity N]
- kronan notes update <line-token> [--text ...] [--quantity N]
- kronan notes remove <line-token>
- kronan notes toggle <line-token>
- kronan notes clear [--force]
- kronan notes archived          View completed items

PURCHASE STATISTICS:
- kronan stats [--limit N] [--offset N] [--include-ignored]
- kronan stats ignore <id>
- kronan stats unignore <id>

Also fixed:
- getMe() response handling (object vs array)
- getShoppingNote() response handling
- Stats command flag parsing

The CLI now mirrors the Krónan Public API comprehensively.
Added documentation for all new commands:
- Categories (browse by category hierarchy)
- Order modifications (delete-lines, lower-quantity, toggle-substitution)
- Product Lists (full CRUD: create, view, delete, add/remove items, clear)
- Shopping Notes (full CRUD for Skundalisti/Scan and Go)
- Purchase Statistics (view history, ignore/unignore products)

Also updated:
- Version to 0.3.0
- Enhanced AI agent usage examples
- Complete API endpoint reference table
- Added version history section
@arnif arnif merged commit efd25de into main Apr 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant