feat(cli): per-resource filter flags on list commands
Adds the filter flags users were reaching for via `--jq` post-filter: - `kb list --pinned` — client-side filter to KBs with `IsPinned`. - `doc list --status <pending|processing|completed|failed>` — server-side query-param filter; `failed` surfaces ingestion errors immediately for triage. - `session list --since <duration>` — client-side filter to sessions updated within the past duration. Accepts time.ParseDuration forms (24h, 1h30m, 30m) plus a `<N>d` suffix for whole days (7d, 0.5d). Server-side filters are forwarded as query params (where the API supports them) to avoid pulling the full list into memory; client-side filters apply after the fetch so they compose with `--limit`.
This commit is contained in:
@@ -46,7 +46,10 @@ const jsonNoOptSentinel = "\x00json-no-value"
|
||||
// the command's help. Pass nil to skip the help annotation (uncommon).
|
||||
func AddJSONFlags(cmd *cobra.Command, fields []string) {
|
||||
f := cmd.Flags()
|
||||
f.StringSlice("json", nil, "Output JSON envelope; bare `--json` for full, `--json=id,name` for filtered fields")
|
||||
// Backticks reserved for pflag's UnquoteUsage to extract the varname;
|
||||
// avoid them in the description so the help doesn't render the flag
|
||||
// name twice.
|
||||
f.StringSlice("json", nil, "Output JSON envelope (bare for full; --json=id,name for `fields`)")
|
||||
f.Lookup("json").NoOptDefVal = jsonNoOptSentinel
|
||||
f.StringP("jq", "q", "", "Filter JSON output using a jq `expression` (requires --json)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user