Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=<json>, or name=@file (repeatable)")
flags.Bool("dry-run", false, "Validate and print request, don't execute")
Expand Down
Loading