diff --git a/cmd/api_test.go b/cmd/api_test.go index 91f0644..6325893 100644 --- a/cmd/api_test.go +++ b/cmd/api_test.go @@ -666,6 +666,22 @@ func TestAPI_JQMatchingWriteIsUnchanged(t *testing.T) { } } +func TestAPI_JQCompactFlagAccepted(t *testing.T) { + server, cleanup := setupAPITest(t) + defer cleanup() + + stdout, _, err := executeCommand("api", "/v1/environments/{environment_id}/campaigns", + "--api-url", server.URL, + "--params", `{"environment_id": "456"}`, + "--jq", "{method, path}", "-c") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if strings.TrimSpace(stdout) != `{"method":"GET","path":"/v1/environments/456/campaigns"}` { + t.Errorf("expected compact projection, got %q", stdout) + } +} + func TestAPI_JQPathMissingFromReadWarns(t *testing.T) { server, cleanup := setupAPITest(t) defer cleanup() diff --git a/cmd/root.go b/cmd/root.go index 8207d86..e45b56e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -69,6 +69,9 @@ func init() { flags.StringArray("params", nil, `Query parameters as a JSON object, e.g. '{"email":"a@b.com"}' (query-string form 'email=a@b.com' also accepted; encode spaces as %20 and a plus as %2B). Repeatable; each key may appear only once`) flags.String("jq", "", "jq expression filter (via gojq)") flags.BoolP("raw-output", "r", false, "Print string results unquoted, like jq -r (no external jq needed)") + // Agents add jq's -c out of habit; output is always compact, so accept it instead of failing the command. + flags.BoolP("compact-output", "c", false, "Accepted for jq compatibility; output is already compact JSON") + _ = flags.MarkHidden("compact-output") flags.StringArray("arg", nil, "Bind a string variable for --json's jq program: --arg name=value, or name=@file to read the value from a file (repeatable). Makes --json a jq -n program — no external jq needed") flags.StringArray("argjson", nil, "Bind a JSON variable for --json's jq program: --argjson name=, or name=@file (repeatable)") flags.Bool("dry-run", false, "Validate and print request, don't execute")