Add compare and tui commands with shared sort/filter CLI wiring

- add pubcli compare command to rank nearby stores by filtered deal coverage, bogo count, aggregate score, and distance tie-breaks
- support --count (1-10) for comparison breadth and emit structured JSON/text output with ranked entries
- add robust distance token parsing to tolerate upstream distance string formatting differences
- add pubcli tui interactive terminal browser with paging, deal detail drill-in, and explicit TTY validation for stdin/stdout
- share deal-filter flag registration across root/tui/compare and add --sort support in root execution path
- validate sort mode early and allow canonical aliases (end, expiry, expiration) while preserving explicit invalid-arg guidance
- expand tolerant CLI normalization for new commands/flags and aliases (orderby, sortby, count, bare-flag rewrite for compare/tui)
- update quick-start flag list and integration tests to cover compare help and normalization behavior
This commit is contained in:
2026-02-23 00:27:18 -05:00
parent eb2328b768
commit 7dd963141a
7 changed files with 428 additions and 15 deletions

View File

@@ -18,13 +18,17 @@ var knownFlags = map[string]flagSpec{
"department": {name: "department", requiresValue: true},
"bogo": {name: "bogo", requiresValue: false},
"query": {name: "query", requiresValue: true},
"sort": {name: "sort", requiresValue: true},
"limit": {name: "limit", requiresValue: true},
"count": {name: "count", requiresValue: true},
"help": {name: "help", requiresValue: false},
}
var knownCommands = []string{
"categories",
"stores",
"compare",
"tui",
"completion",
"help",
}
@@ -36,6 +40,8 @@ var flagAliases = map[string]string{
"storeno": "store",
"dept": "department",
"search": "query",
"orderby": "sort",
"sortby": "sort",
"max": "limit",
}
@@ -156,7 +162,7 @@ func bareFlagRewriteAllowed(command string) bool {
// Some commands (for example `stores` and `categories`) are flag-only, so
// rewriting bare tokens like `zip` -> `--zip` is helpful there.
switch command {
case "stores", "categories":
case "stores", "categories", "compare", "tui":
return true
default:
return false