From b25c8cb53998ae20441273aa550a0b435b608bf3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 22:13:16 +0000 Subject: [PATCH 01/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3183fac..81083cd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.6.0 + github.com/agentmail-to/agentmail-go v0.8.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 550ec0a..1089e67 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.6.0 h1:CCQtBbYE97KASraV2v4IvSuaaJrjKDn97qH1rhMmJt8= -github.com/agentmail-to/agentmail-go v0.6.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.8.0 h1:7Ek7UHIO0U2rrN6ib2gL1/W3LEkHdQfvQsHu0j3T+CQ= +github.com/agentmail-to/agentmail-go v0.8.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From fbfe2c1e0e56a779a885443c2d0d4743b512e242 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:52:03 +0000 Subject: [PATCH 02/31] chore(cli): fall back to JSON when using default "explore" with non-TTY --- cmd/agentmail/main.go | 2 +- pkg/cmd/agent.go | 6 ++-- pkg/cmd/apikey.go | 6 ++-- pkg/cmd/cmdutil.go | 29 +++++++++++++---- pkg/cmd/cmdutil_test.go | 70 ++++++++++++++++++++++++++++++++++++++++- pkg/cmd/domain.go | 12 ++++--- pkg/cmd/draft.go | 9 ++++-- pkg/cmd/inbox.go | 15 ++++++--- pkg/cmd/inboxapikey.go | 6 ++-- pkg/cmd/inboxdraft.go | 18 +++++++---- pkg/cmd/inboxlist.go | 9 ++++-- pkg/cmd/inboxmessage.go | 27 ++++++++++------ pkg/cmd/inboxthread.go | 9 ++++-- pkg/cmd/list.go | 9 ++++-- pkg/cmd/metric.go | 3 +- pkg/cmd/organization.go | 3 +- pkg/cmd/pod.go | 9 ++++-- pkg/cmd/podapikey.go | 6 ++-- pkg/cmd/poddomain.go | 12 ++++--- pkg/cmd/poddraft.go | 9 ++++-- pkg/cmd/podinbox.go | 12 ++++--- pkg/cmd/podlist.go | 9 ++++-- pkg/cmd/podmetric.go | 3 +- pkg/cmd/podthread.go | 9 ++++-- pkg/cmd/thread.go | 9 ++++-- pkg/cmd/webhook.go | 12 ++++--- 26 files changed, 241 insertions(+), 82 deletions(-) diff --git a/cmd/agentmail/main.go b/cmd/agentmail/main.go index a8702f2..6853420 100644 --- a/cmd/agentmail/main.go +++ b/cmd/agentmail/main.go @@ -43,7 +43,7 @@ func main() { fmt.Fprintf(os.Stderr, "%s %q: %d %s\n", apierr.Request.Method, apierr.Request.URL, apierr.Response.StatusCode, http.StatusText(apierr.Response.StatusCode)) format := app.String("format-error") json := gjson.Parse(apierr.RawJSON()) - show_err := cmd.ShowJSON(os.Stdout, "Error", json, format, app.String("transform-error")) + show_err := cmd.ShowJSON(os.Stdout, os.Stderr, "Error", json, format, app.IsSet("format-error"), app.String("transform-error")) if show_err != nil { // Just print the original error: fmt.Fprintf(os.Stderr, "%s\n", err.Error()) diff --git a/pkg/cmd/agent.go b/pkg/cmd/agent.go index 03ee71b..b446260 100644 --- a/pkg/cmd/agent.go +++ b/pkg/cmd/agent.go @@ -83,8 +83,9 @@ func handleAgentSignUp(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "agent sign-up", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "agent sign-up", obj, format, explicitFormat, transform) } func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { @@ -117,6 +118,7 @@ func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "agent verify", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "agent verify", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/apikey.go b/pkg/cmd/apikey.go index c93f3c8..28a95d6 100644 --- a/pkg/cmd/apikey.go +++ b/pkg/cmd/apikey.go @@ -283,8 +283,9 @@ func handleAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "api-keys create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "api-keys create", obj, format, explicitFormat, transform) } func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -317,8 +318,9 @@ func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "api-keys list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "api-keys list", obj, format, explicitFormat, transform) } func handleAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index 75c8b90..d0d9826 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -366,8 +366,13 @@ func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format } } -// Display JSON to the user in various different formats -func ShowJSON(out *os.File, title string, res gjson.Result, format string, transform string) error { +const warningExploreNotSupported = "Warning: Output format 'explore' not supported for non-terminal output; falling back to 'json'\n" + +// Display JSON to the user in various different formats. The explicitFormat parameter indicates +// whether the format was explicitly set by the user (via --format), which controls whether we +// silently fall back to json when explore is requested on non-terminal output. Warnings are +// written to stderr. +func ShowJSON(out *os.File, stderr io.Writer, title string, res gjson.Result, format string, explicitFormat bool, transform string) error { if transform != "" { transformed := res.Get(transform) if transformed.Exists() { @@ -377,8 +382,14 @@ func ShowJSON(out *os.File, title string, res gjson.Result, format string, trans switch strings.ToLower(format) { case "auto": - return ShowJSON(out, title, res, "json", "") + return ShowJSON(out, stderr, title, res, "json", explicitFormat, "") case "explore": + if !isTerminal(out) { + if explicitFormat { + fmt.Fprint(stderr, warningExploreNotSupported) + } + return ShowJSON(out, stderr, title, res, "json", explicitFormat, transform) + } return jsonview.ExploreJSON(title, res) default: bytes, err := formatJSON(out, title, res, format, transform) @@ -403,9 +414,15 @@ type hasRawJSON interface { // For an iterator over different value types, display its values to the user in // different formats. // -1 is used to signal no limit of items to display -func ShowJSONIterator[T any](stdout *os.File, title string, iter jsonview.Iterator[T], format string, transform string, itemsToDisplay int64) error { +func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, iter jsonview.Iterator[T], format string, explicitFormat bool, transform string, itemsToDisplay int64) error { if format == "explore" { - return jsonview.ExploreJSONStream(title, iter) + if isTerminal(stdout) { + return jsonview.ExploreJSONStream(title, iter) + } + if explicitFormat { + fmt.Fprint(stderr, warningExploreNotSupported) + } + format = "json" } terminalWidth, terminalHeight, err := term.GetSize(os.Stdout.Fd()) @@ -478,7 +495,7 @@ func ShowJSONIterator[T any](stdout *os.File, title string, iter jsonview.Iterat } obj = gjson.ParseBytes(jsonData) } - if err := ShowJSON(pager, title, obj, format, transform); err != nil { + if err := ShowJSON(pager, stderr, title, obj, format, explicitFormat, transform); err != nil { return err } itemsToDisplay -= 1 diff --git a/pkg/cmd/cmdutil_test.go b/pkg/cmd/cmdutil_test.go index 66e3b07..ba5e3f0 100644 --- a/pkg/cmd/cmdutil_test.go +++ b/pkg/cmd/cmdutil_test.go @@ -231,6 +231,73 @@ func TestShowJSONIterator(t *testing.T) { }) } +func TestExploreFallback(t *testing.T) { + t.Parallel() + + t.Run("ShowJSONFallsBackToJsonOnNonTTY", func(t *testing.T) { + t.Parallel() + + // os.Pipe() produces a *os.File that isn't a terminal, so explore should fall back. + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + + var stderr bytes.Buffer + res := gjson.Parse(`{"id":"abc"}`) + err = ShowJSON(w, &stderr, "test", res, "explore", false, "") + w.Close() + require.NoError(t, err) + + var buf bytes.Buffer + _, _ = buf.ReadFrom(r) + assert.Contains(t, buf.String(), `"id"`) + assert.Contains(t, buf.String(), `"abc"`) + }) + + t.Run("ShowJSONIteratorFallsBackToJsonOnNonTTY", func(t *testing.T) { + t.Parallel() + + iter := &sliceIterator[map[string]any]{items: []map[string]any{ + {"id": "abc"}, + }} + captured := captureShowJSONIterator(t, iter, "explore", "", -1) + assert.Contains(t, captured, `"id"`) + assert.Contains(t, captured, `"abc"`) + }) + + t.Run("ShowJSONWarnsWhenExplicitFormatOnNonTTY", func(t *testing.T) { + t.Parallel() + + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + + var stderr bytes.Buffer + res := gjson.Parse(`{"id":"abc"}`) + err = ShowJSON(w, &stderr, "test", res, "explore", true, "") + w.Close() + require.NoError(t, err) + + assert.Equal(t, warningExploreNotSupported, stderr.String()) + }) + + t.Run("ShowJSONSilentWhenDefaultFormatOnNonTTY", func(t *testing.T) { + t.Parallel() + + r, w, err := os.Pipe() + require.NoError(t, err) + defer r.Close() + + var stderr bytes.Buffer + res := gjson.Parse(`{"id":"abc"}`) + err = ShowJSON(w, &stderr, "test", res, "explore", false, "") + w.Close() + require.NoError(t, err) + + assert.Empty(t, stderr.String(), "no warning expected when format was not explicit") + }) +} + // sliceIterator is a simple iterator over a slice for testing. type sliceIterator[T any] struct { index int @@ -260,7 +327,8 @@ func captureShowJSONIterator[T any](t *testing.T, iter jsonview.Iterator[T], for require.NoError(t, err) defer r.Close() - err = ShowJSONIterator(w, "test", iter, format, transform, itemsToDisplay) + var stderr bytes.Buffer + err = ShowJSONIterator(w, &stderr, "test", iter, format, false, transform, itemsToDisplay) w.Close() require.NoError(t, err) diff --git a/pkg/cmd/domain.go b/pkg/cmd/domain.go index df45bb1..62a5dcd 100644 --- a/pkg/cmd/domain.go +++ b/pkg/cmd/domain.go @@ -172,8 +172,9 @@ func handleDomainsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "domains create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "domains create", obj, format, explicitFormat, transform) } func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -214,8 +215,9 @@ func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "domains update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "domains update", obj, format, explicitFormat, transform) } func handleDomainsList(ctx context.Context, cmd *cli.Command) error { @@ -248,8 +250,9 @@ func handleDomainsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "domains list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "domains list", obj, format, explicitFormat, transform) } func handleDomainsDelete(ctx context.Context, cmd *cli.Command) error { @@ -308,8 +311,9 @@ func handleDomainsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "domains get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "domains get", obj, format, explicitFormat, transform) } func handleDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/draft.go b/pkg/cmd/draft.go index e97079a..b7b9ca3 100644 --- a/pkg/cmd/draft.go +++ b/pkg/cmd/draft.go @@ -120,8 +120,9 @@ func handleDraftsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "drafts list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "drafts list", obj, format, explicitFormat, transform) } func handleDraftsGet(ctx context.Context, cmd *cli.Command) error { @@ -155,8 +156,9 @@ func handleDraftsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "drafts get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "drafts get", obj, format, explicitFormat, transform) } func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -199,6 +201,7 @@ func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "drafts get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "drafts get-attachment", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/inbox.go b/pkg/cmd/inbox.go index 5ef6d17..68bb4ae 100644 --- a/pkg/cmd/inbox.go +++ b/pkg/cmd/inbox.go @@ -196,8 +196,9 @@ func handleInboxesCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes create", obj, format, explicitFormat, transform) } func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { @@ -238,8 +239,9 @@ func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes update", obj, format, explicitFormat, transform) } func handleInboxesList(ctx context.Context, cmd *cli.Command) error { @@ -272,8 +274,9 @@ func handleInboxesList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes list", obj, format, explicitFormat, transform) } func handleInboxesDelete(ctx context.Context, cmd *cli.Command) error { @@ -332,8 +335,9 @@ func handleInboxesGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes get", obj, format, explicitFormat, transform) } func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { @@ -374,6 +378,7 @@ func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes list-metrics", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes list-metrics", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/inboxapikey.go b/pkg/cmd/inboxapikey.go index eb44d6d..7a1b8f9 100644 --- a/pkg/cmd/inboxapikey.go +++ b/pkg/cmd/inboxapikey.go @@ -301,8 +301,9 @@ func handleInboxesAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:api-keys create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:api-keys create", obj, format, explicitFormat, transform) } func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -343,8 +344,9 @@ func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:api-keys list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:api-keys list", obj, format, explicitFormat, transform) } func handleInboxesAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/inboxdraft.go b/pkg/cmd/inboxdraft.go index a51e315..514dfa1 100644 --- a/pkg/cmd/inboxdraft.go +++ b/pkg/cmd/inboxdraft.go @@ -361,8 +361,9 @@ func handleInboxesDraftsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts create", obj, format, explicitFormat, transform) } func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -405,8 +406,9 @@ func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts update", obj, format, explicitFormat, transform) } func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { @@ -447,8 +449,9 @@ func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts list", obj, format, explicitFormat, transform) } func handleInboxesDraftsDelete(ctx context.Context, cmd *cli.Command) error { @@ -525,8 +528,9 @@ func handleInboxesDraftsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts get", obj, format, explicitFormat, transform) } func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -570,8 +574,9 @@ func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) err obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts get-attachment", obj, format, explicitFormat, transform) } func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { @@ -614,6 +619,7 @@ func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:drafts send", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts send", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/inboxlist.go b/pkg/cmd/inboxlist.go index 9fe9be2..9e3fcef 100644 --- a/pkg/cmd/inboxlist.go +++ b/pkg/cmd/inboxlist.go @@ -185,8 +185,9 @@ func handleInboxesListsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:lists create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists create", obj, format, explicitFormat, transform) } func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { @@ -230,8 +231,9 @@ func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:lists list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists list", obj, format, explicitFormat, transform) } func handleInboxesListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -312,6 +314,7 @@ func handleInboxesListsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:lists get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index 7278ad5..0360b6a 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -584,8 +584,9 @@ func handleInboxesMessagesUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages update", obj, format, explicitFormat, transform) } func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { @@ -626,8 +627,9 @@ func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages list", obj, format, explicitFormat, transform) } func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { @@ -670,8 +672,9 @@ func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages forward", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages forward", obj, format, explicitFormat, transform) } func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { @@ -714,8 +717,9 @@ func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get", obj, format, explicitFormat, transform) } func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -759,8 +763,9 @@ func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) e obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get-attachment", obj, format, explicitFormat, transform) } func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { @@ -803,8 +808,9 @@ func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages get-raw", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get-raw", obj, format, explicitFormat, transform) } func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { @@ -847,8 +853,9 @@ func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages reply", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages reply", obj, format, explicitFormat, transform) } func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error { @@ -891,8 +898,9 @@ func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages reply-all", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages reply-all", obj, format, explicitFormat, transform) } func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { @@ -933,6 +941,7 @@ func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:messages send", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages send", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index d679a57..f46448c 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -183,8 +183,9 @@ func handleInboxesThreadsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:threads list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads list", obj, format, explicitFormat, transform) } func handleInboxesThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -261,8 +262,9 @@ func handleInboxesThreadsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:threads get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads get", obj, format, explicitFormat, transform) } func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -306,6 +308,7 @@ func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) er obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "inboxes:threads get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads get-attachment", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 8442109..3a481ff 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -164,8 +164,9 @@ func handleListsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "lists create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "lists create", obj, format, explicitFormat, transform) } func handleListsList(ctx context.Context, cmd *cli.Command) error { @@ -208,8 +209,9 @@ func handleListsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "lists list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "lists list", obj, format, explicitFormat, transform) } func handleListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -288,6 +290,7 @@ func handleListsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "lists get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "lists get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/metric.go b/pkg/cmd/metric.go index 7b1768b..f85c0b5 100644 --- a/pkg/cmd/metric.go +++ b/pkg/cmd/metric.go @@ -85,6 +85,7 @@ func handleMetricsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "metrics list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "metrics list", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/organization.go b/pkg/cmd/organization.go index d2aea0f..88a392c 100644 --- a/pkg/cmd/organization.go +++ b/pkg/cmd/organization.go @@ -51,6 +51,7 @@ func handleOrganizationsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "organizations get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "organizations get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/pod.go b/pkg/cmd/pod.go index 64243e3..fb7fba4 100644 --- a/pkg/cmd/pod.go +++ b/pkg/cmd/pod.go @@ -120,8 +120,9 @@ func handlePodsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods create", obj, format, explicitFormat, transform) } func handlePodsList(ctx context.Context, cmd *cli.Command) error { @@ -154,8 +155,9 @@ func handlePodsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods list", obj, format, explicitFormat, transform) } func handlePodsDelete(ctx context.Context, cmd *cli.Command) error { @@ -214,6 +216,7 @@ func handlePodsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/podapikey.go b/pkg/cmd/podapikey.go index 3b47191..6853129 100644 --- a/pkg/cmd/podapikey.go +++ b/pkg/cmd/podapikey.go @@ -301,8 +301,9 @@ func handlePodsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:api-keys create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:api-keys create", obj, format, explicitFormat, transform) } func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -343,8 +344,9 @@ func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:api-keys list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:api-keys list", obj, format, explicitFormat, transform) } func handlePodsAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/poddomain.go b/pkg/cmd/poddomain.go index 92b31bd..28aa494 100644 --- a/pkg/cmd/poddomain.go +++ b/pkg/cmd/poddomain.go @@ -215,8 +215,9 @@ func handlePodsDomainsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:domains create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:domains create", obj, format, explicitFormat, transform) } func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -259,8 +260,9 @@ func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:domains update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:domains update", obj, format, explicitFormat, transform) } func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { @@ -301,8 +303,9 @@ func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:domains list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:domains list", obj, format, explicitFormat, transform) } func handlePodsDomainsDelete(ctx context.Context, cmd *cli.Command) error { @@ -379,8 +382,9 @@ func handlePodsDomainsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:domains get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:domains get", obj, format, explicitFormat, transform) } func handlePodsDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/poddraft.go b/pkg/cmd/poddraft.go index 1ecf2bc..5f204f2 100644 --- a/pkg/cmd/poddraft.go +++ b/pkg/cmd/poddraft.go @@ -143,8 +143,9 @@ func handlePodsDraftsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:drafts list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:drafts list", obj, format, explicitFormat, transform) } func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { @@ -187,8 +188,9 @@ func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:drafts get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:drafts get", obj, format, explicitFormat, transform) } func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -232,6 +234,7 @@ func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:drafts get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:drafts get-attachment", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/podinbox.go b/pkg/cmd/podinbox.go index aa0729b..39436f8 100644 --- a/pkg/cmd/podinbox.go +++ b/pkg/cmd/podinbox.go @@ -184,8 +184,9 @@ func handlePodsInboxesCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:inboxes create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes create", obj, format, explicitFormat, transform) } func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { @@ -228,8 +229,9 @@ func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:inboxes update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes update", obj, format, explicitFormat, transform) } func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { @@ -270,8 +272,9 @@ func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:inboxes list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes list", obj, format, explicitFormat, transform) } func handlePodsInboxesDelete(ctx context.Context, cmd *cli.Command) error { @@ -348,6 +351,7 @@ func handlePodsInboxesGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:inboxes get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/podlist.go b/pkg/cmd/podlist.go index 10c0a14..7eca84a 100644 --- a/pkg/cmd/podlist.go +++ b/pkg/cmd/podlist.go @@ -185,8 +185,9 @@ func handlePodsListsCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:lists create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:lists create", obj, format, explicitFormat, transform) } func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { @@ -230,8 +231,9 @@ func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:lists list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:lists list", obj, format, explicitFormat, transform) } func handlePodsListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -312,6 +314,7 @@ func handlePodsListsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:lists get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:lists get", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/podmetric.go b/pkg/cmd/podmetric.go index 88579b1..33109b5 100644 --- a/pkg/cmd/podmetric.go +++ b/pkg/cmd/podmetric.go @@ -98,6 +98,7 @@ func handlePodsMetricsQuery(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:metrics query", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:metrics query", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index 92ce97d..811bfef 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -183,8 +183,9 @@ func handlePodsThreadsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:threads list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:threads list", obj, format, explicitFormat, transform) } func handlePodsThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -261,8 +262,9 @@ func handlePodsThreadsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:threads get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:threads get", obj, format, explicitFormat, transform) } func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -306,6 +308,7 @@ func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "pods:threads get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "pods:threads get-attachment", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index c41f595..1007226 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -155,8 +155,9 @@ func handleThreadsList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "threads list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "threads list", obj, format, explicitFormat, transform) } func handleThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -222,8 +223,9 @@ func handleThreadsGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "threads get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "threads get", obj, format, explicitFormat, transform) } func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -266,6 +268,7 @@ func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "threads get-attachment", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "threads get-attachment", obj, format, explicitFormat, transform) } diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index afff2aa..4c1b45b 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -172,8 +172,9 @@ func handleWebhooksCreate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "webhooks create", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "webhooks create", obj, format, explicitFormat, transform) } func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { @@ -214,8 +215,9 @@ func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "webhooks update", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "webhooks update", obj, format, explicitFormat, transform) } func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { @@ -248,8 +250,9 @@ func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "webhooks list", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "webhooks list", obj, format, explicitFormat, transform) } func handleWebhooksDelete(ctx context.Context, cmd *cli.Command) error { @@ -308,6 +311,7 @@ func handleWebhooksGet(ctx context.Context, cmd *cli.Command) error { obj := gjson.ParseBytes(res) format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, "webhooks get", obj, format, transform) + return ShowJSON(os.Stdout, os.Stderr, "webhooks get", obj, format, explicitFormat, transform) } From ea26a8c2a975386b3a00bf181d877e3eeb40c3f1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:53:10 +0000 Subject: [PATCH 03/31] feat(cli): alias parameters in data with `x-stainless-cli-data-alias` --- internal/requestflag/innerflag.go | 19 ++++++++++-- internal/requestflag/requestflag.go | 9 ++++++ pkg/cmd/flagoptions.go | 47 +++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/internal/requestflag/innerflag.go b/internal/requestflag/innerflag.go index 102624f..eeeb8bc 100644 --- a/internal/requestflag/innerflag.go +++ b/internal/requestflag/innerflag.go @@ -22,14 +22,29 @@ type InnerFlag[ Aliases []string // aliases that are allowed for this flag Validator func(T) error // custom function to validate this flag value - OuterFlag cli.Flag // The flag on which this inner flag will set values - InnerField string // The inner field which this flag will set + OuterFlag cli.Flag // The flag on which this inner flag will set values + InnerField string // The inner field which this flag will set + DataAliases []string // alternate names recognized in YAML values passed as the outer flag +} + +// GetDataAliases returns the aliases recognized when parsing inner field keys from piped or flag YAML. +func (f *InnerFlag[T]) GetDataAliases() []string { + return f.DataAliases +} + +// GetInnerField returns the API field name that this inner flag sets on its outer flag's value. +// For example, the flag --parent.foo targeting a parameter whose OpenAPI property name is "foo" +// would return "foo". This is distinct from the flag's CLI name and from any DataAliases entries. +func (f *InnerFlag[T]) GetInnerField() string { + return f.InnerField } type HasOuterFlag interface { cli.Flag SetOuterFlag(cli.Flag) GetOuterFlag() cli.Flag + GetInnerField() string + GetDataAliases() []string } func (f *InnerFlag[T]) SetOuterFlag(flag cli.Flag) { diff --git a/internal/requestflag/requestflag.go b/internal/requestflag/requestflag.go index bdef64f..bfaf064 100644 --- a/internal/requestflag/requestflag.go +++ b/internal/requestflag/requestflag.go @@ -48,6 +48,10 @@ type Flag[ // binary` in the OpenAPI spec. FileInput bool + // DataAliases is a list of alternate names for this parameter recognized when parsing piped YAML/JSON + // input. Values keyed by any alias are translated to the canonical API name before being sent. + DataAliases []string + // unexported fields for internal use count int // number of times the flag has been set hasBeenSet bool // whether the flag has been set from env or file @@ -65,6 +69,7 @@ type InRequest interface { GetBodyPath() string IsBodyRoot() bool IsFileInput() bool + GetDataAliases() []string } func (f Flag[T]) GetQueryPath() string { @@ -87,6 +92,10 @@ func (f Flag[T]) IsFileInput() bool { return f.FileInput } +func (f Flag[T]) GetDataAliases() []string { + return f.DataAliases +} + // The values that will be sent in different parts of a request. type RequestContents struct { Queries map[string]any diff --git a/pkg/cmd/flagoptions.go b/pkg/cmd/flagoptions.go index 0d94ce4..9eb5221 100644 --- a/pkg/cmd/flagoptions.go +++ b/pkg/cmd/flagoptions.go @@ -309,6 +309,12 @@ func flagOptions( requestContents := requestflag.ExtractRequestContents(cmd) + // Translate inner-field aliases in YAML values that came from flags (e.g. + // `--parent '{"alias": val}'` resolving to the canonical inner field). + if bodyMap, ok := requestContents.Body.(map[string]any); ok { + applyDataAliases(cmd, bodyMap) + } + stdinConsumedByPipe := false if (bodyType == MultipartFormEncoded || bodyType == ApplicationJSON) && !ignoreStdin && isInputPiped() { pipeData, err := io.ReadAll(os.Stdin) @@ -323,6 +329,7 @@ func flagOptions( return nil, fmt.Errorf("Failed to parse piped data as YAML/JSON:\n%w", err) } if bodyMap, ok := bodyData.(map[string]any); ok { + applyDataAliases(cmd, bodyMap) if flagMap, ok := requestContents.Body.(map[string]any); ok { maps.Copy(bodyMap, flagMap) requestContents.Body = bodyMap @@ -485,6 +492,46 @@ func flagOptions( // as a file path without needing the "@" prefix. type FilePathValue string +// applyDataAliases rewrites keys in a body map based on flag `DataAliases` metadata. For top-level flags, +// `{alias: value}` becomes `{canonical: value}`. For inner flags (those registered under an outer flag +// via WithInnerFlags), the alias translation is also applied to the nested map under the outer flag's +// body path, so values like `--parent '{"alias": val}'` resolve to the canonical inner field name. +func applyDataAliases(cmd *cli.Command, bodyMap map[string]any) { + for _, flag := range cmd.Flags { + // Inner flags: rewrite aliases inside the nested map under the outer flag's body path. + if inner, ok := flag.(requestflag.HasOuterFlag); ok { + outer, outerOk := inner.GetOuterFlag().(requestflag.InRequest) + if !outerOk { + continue + } + if nested, ok := bodyMap[outer.GetBodyPath()].(map[string]any); ok && inner.GetInnerField() != "" { + rewriteAliases(nested, inner.GetInnerField(), inner.GetDataAliases()) + } + continue + } + // Top-level flags: rewrite aliases in the body map. + if inReq, ok := flag.(requestflag.InRequest); ok && inReq.GetBodyPath() != "" { + rewriteAliases(bodyMap, inReq.GetBodyPath(), inReq.GetDataAliases()) + } + } +} + +// rewriteAliases replaces each alias key in m with the canonical key, preserving the value. The +// "canonical" key is the name the API itself expects (the OpenAPI property/field name) — e.g. for +// a top-level flag, the parameter's BodyPath; for an inner flag, the inner field name. Aliases are +// the user-facing alternate names declared via x-stainless-cli-data-alias. +func rewriteAliases(m map[string]any, canonical string, aliases []string) { + for _, alias := range aliases { + if alias == "" || alias == canonical { + continue + } + if val, exists := m[alias]; exists { + m[canonical] = val + delete(m, alias) + } + } +} + // wrapFileInputValues replaces string values for FileInput flags (type: string, format: binary) with // FilePathValue sentinel values. embedFilesValue recognizes FilePathValue and reads the file contents // directly, so the user doesn't need to type the "@" prefix. This handles both values set via explicit From d227554129ec4bddcf6ba84af9f08fe49247ea82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 03:23:12 +0000 Subject: [PATCH 04/31] chore(cli): switch long lists of positional args over to param structs --- cmd/agentmail/main.go | 7 +++- pkg/cmd/agent.go | 15 ++++++-- pkg/cmd/apikey.go | 15 ++++++-- pkg/cmd/cmdutil.go | 84 +++++++++++++++++++++++++++-------------- pkg/cmd/cmdutil_test.go | 31 ++++++++++++--- pkg/cmd/domain.go | 29 +++++++++++--- pkg/cmd/draft.go | 22 +++++++++-- pkg/cmd/inbox.go | 36 +++++++++++++++--- pkg/cmd/inboxapikey.go | 15 ++++++-- pkg/cmd/inboxdraft.go | 43 +++++++++++++++++---- pkg/cmd/inboxlist.go | 22 +++++++++-- pkg/cmd/inboxmessage.go | 64 ++++++++++++++++++++++++++----- pkg/cmd/inboxthread.go | 22 +++++++++-- pkg/cmd/list.go | 22 +++++++++-- pkg/cmd/metric.go | 8 +++- pkg/cmd/organization.go | 8 +++- pkg/cmd/pod.go | 22 +++++++++-- pkg/cmd/podapikey.go | 15 ++++++-- pkg/cmd/poddomain.go | 29 +++++++++++--- pkg/cmd/poddraft.go | 22 +++++++++-- pkg/cmd/podinbox.go | 29 +++++++++++--- pkg/cmd/podlist.go | 22 +++++++++-- pkg/cmd/podmetric.go | 8 +++- pkg/cmd/podthread.go | 22 +++++++++-- pkg/cmd/thread.go | 22 +++++++++-- pkg/cmd/webhook.go | 29 +++++++++++--- 26 files changed, 531 insertions(+), 132 deletions(-) diff --git a/cmd/agentmail/main.go b/cmd/agentmail/main.go index 6853420..6cb588d 100644 --- a/cmd/agentmail/main.go +++ b/cmd/agentmail/main.go @@ -43,7 +43,12 @@ func main() { fmt.Fprintf(os.Stderr, "%s %q: %d %s\n", apierr.Request.Method, apierr.Request.URL, apierr.Response.StatusCode, http.StatusText(apierr.Response.StatusCode)) format := app.String("format-error") json := gjson.Parse(apierr.RawJSON()) - show_err := cmd.ShowJSON(os.Stdout, os.Stderr, "Error", json, format, app.IsSet("format-error"), app.String("transform-error")) + show_err := cmd.ShowJSON(json, cmd.ShowJSONOpts{ + ExplicitFormat: app.IsSet("format-error"), + Format: format, + Title: "Error", + Transform: app.String("transform-error"), + }) if show_err != nil { // Just print the original error: fmt.Fprintf(os.Stderr, "%s\n", err.Error()) diff --git a/pkg/cmd/agent.go b/pkg/cmd/agent.go index b446260..9b2cbea 100644 --- a/pkg/cmd/agent.go +++ b/pkg/cmd/agent.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -85,7 +84,12 @@ func handleAgentSignUp(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "agent sign-up", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "agent sign-up", + Transform: transform, + }) } func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { @@ -120,5 +124,10 @@ func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "agent verify", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "agent verify", + Transform: transform, + }) } diff --git a/pkg/cmd/apikey.go b/pkg/cmd/apikey.go index 28a95d6..4800ce7 100644 --- a/pkg/cmd/apikey.go +++ b/pkg/cmd/apikey.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -285,7 +284,12 @@ func handleAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "api-keys create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "api-keys create", + Transform: transform, + }) } func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -320,7 +324,12 @@ func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "api-keys list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "api-keys list", + Transform: transform, + }) } func handleAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index d0d9826..d15bae7 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -368,36 +368,58 @@ func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format const warningExploreNotSupported = "Warning: Output format 'explore' not supported for non-terminal output; falling back to 'json'\n" -// Display JSON to the user in various different formats. The explicitFormat parameter indicates -// whether the format was explicitly set by the user (via --format), which controls whether we -// silently fall back to json when explore is requested on non-terminal output. Warnings are -// written to stderr. -func ShowJSON(out *os.File, stderr io.Writer, title string, res gjson.Result, format string, explicitFormat bool, transform string) error { - if transform != "" { - transformed := res.Get(transform) +// ShowJSONOpts configures how JSON output is displayed. +type ShowJSONOpts struct { + ExplicitFormat bool // true if the user explicitly passed --format + Format string // output format (auto, explore, json, jsonl, pretty, raw, yaml) + Stderr io.Writer // stderr for warnings; injectable for testing; defaults to os.Stderr + Stdout *os.File // stdout (or pager); injectable for testing; defaults to os.Stdout + Title string // display title + Transform string // GJSON path to extract before displaying +} + +func (o *ShowJSONOpts) setDefaults() { + if o.Stderr == nil { + o.Stderr = os.Stderr + } + if o.Stdout == nil { + o.Stdout = os.Stdout + } +} + +// ShowJSON displays a single JSON result to the user. +func ShowJSON(res gjson.Result, opts ShowJSONOpts) error { + opts.setDefaults() + + if opts.Transform != "" { + transformed := res.Get(opts.Transform) if transformed.Exists() { res = transformed } } - switch strings.ToLower(format) { + switch strings.ToLower(opts.Format) { case "auto": - return ShowJSON(out, stderr, title, res, "json", explicitFormat, "") + jsonOpts := opts + jsonOpts.Format = "json" + return ShowJSON(res, jsonOpts) case "explore": - if !isTerminal(out) { - if explicitFormat { - fmt.Fprint(stderr, warningExploreNotSupported) + if !isTerminal(opts.Stdout) { + if opts.ExplicitFormat { + fmt.Fprint(opts.Stderr, warningExploreNotSupported) } - return ShowJSON(out, stderr, title, res, "json", explicitFormat, transform) + jsonOpts := opts + jsonOpts.Format = "json" + return ShowJSON(res, jsonOpts) } - return jsonview.ExploreJSON(title, res) + return jsonview.ExploreJSON(opts.Title, res) default: - bytes, err := formatJSON(out, title, res, format, transform) + bytes, err := formatJSON(opts.Stdout, opts.Title, res, opts.Format, opts.Transform) if err != nil { return err } - _, err = out.Write(bytes) + _, err = opts.Stdout.Write(bytes) return err } } @@ -411,16 +433,17 @@ type hasRawJSON interface { RawJSON() string } -// For an iterator over different value types, display its values to the user in -// different formats. -// -1 is used to signal no limit of items to display -func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, iter jsonview.Iterator[T], format string, explicitFormat bool, transform string, itemsToDisplay int64) error { +// ShowJSONIterator displays an iterator of values to the user. Use itemsToDisplay = -1 for no limit. +func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, opts ShowJSONOpts) error { + opts.setDefaults() + + format := opts.Format if format == "explore" { - if isTerminal(stdout) { - return jsonview.ExploreJSONStream(title, iter) + if isTerminal(opts.Stdout) { + return jsonview.ExploreJSONStream(opts.Title, iter) } - if explicitFormat { - fmt.Fprint(stderr, warningExploreNotSupported) + if opts.ExplicitFormat { + fmt.Fprint(opts.Stderr, warningExploreNotSupported) } format = "json" } @@ -448,7 +471,7 @@ func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, it } obj = gjson.ParseBytes(jsonData) } - json, err := formatJSON(stdout, title, obj, format, transform) + json, err := formatJSON(opts.Stdout, opts.Title, obj, format, opts.Transform) if err != nil { return err } @@ -465,7 +488,7 @@ func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, it } if !usePager { - _, err := stdout.Write(output) + _, err := opts.Stdout.Write(output) if err != nil { return err } @@ -473,13 +496,16 @@ func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, it return iter.Err() } - return streamOutput(title, func(pager *os.File) error { - // Write the output we used during the initial terminal size computation + return streamOutput(opts.Title, func(pager *os.File) error { _, err := pager.Write(output) if err != nil { return err } + pagerOpts := opts + pagerOpts.Format = format + pagerOpts.Stdout = pager + for iter.Next() { if itemsToDisplay == 0 { break @@ -495,7 +521,7 @@ func ShowJSONIterator[T any](stdout *os.File, stderr io.Writer, title string, it } obj = gjson.ParseBytes(jsonData) } - if err := ShowJSON(pager, stderr, title, obj, format, explicitFormat, transform); err != nil { + if err := ShowJSON(obj, pagerOpts); err != nil { return err } itemsToDisplay -= 1 diff --git a/pkg/cmd/cmdutil_test.go b/pkg/cmd/cmdutil_test.go index ba5e3f0..a5799aa 100644 --- a/pkg/cmd/cmdutil_test.go +++ b/pkg/cmd/cmdutil_test.go @@ -244,7 +244,12 @@ func TestExploreFallback(t *testing.T) { var stderr bytes.Buffer res := gjson.Parse(`{"id":"abc"}`) - err = ShowJSON(w, &stderr, "test", res, "explore", false, "") + err = ShowJSON(res, ShowJSONOpts{ + Format: "explore", + Stderr: &stderr, + Stdout: w, + Title: "test", + }) w.Close() require.NoError(t, err) @@ -274,7 +279,13 @@ func TestExploreFallback(t *testing.T) { var stderr bytes.Buffer res := gjson.Parse(`{"id":"abc"}`) - err = ShowJSON(w, &stderr, "test", res, "explore", true, "") + err = ShowJSON(res, ShowJSONOpts{ + ExplicitFormat: true, + Format: "explore", + Stderr: &stderr, + Stdout: w, + Title: "test", + }) w.Close() require.NoError(t, err) @@ -290,7 +301,12 @@ func TestExploreFallback(t *testing.T) { var stderr bytes.Buffer res := gjson.Parse(`{"id":"abc"}`) - err = ShowJSON(w, &stderr, "test", res, "explore", false, "") + err = ShowJSON(res, ShowJSONOpts{ + Format: "explore", + Stderr: &stderr, + Stdout: w, + Title: "test", + }) w.Close() require.NoError(t, err) @@ -327,8 +343,13 @@ func captureShowJSONIterator[T any](t *testing.T, iter jsonview.Iterator[T], for require.NoError(t, err) defer r.Close() - var stderr bytes.Buffer - err = ShowJSONIterator(w, &stderr, "test", iter, format, false, transform, itemsToDisplay) + err = ShowJSONIterator(iter, itemsToDisplay, ShowJSONOpts{ + Format: format, + Stderr: io.Discard, + Stdout: w, + Title: "test", + Transform: transform, + }) w.Close() require.NoError(t, err) diff --git a/pkg/cmd/domain.go b/pkg/cmd/domain.go index 62a5dcd..84ff5ca 100644 --- a/pkg/cmd/domain.go +++ b/pkg/cmd/domain.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -174,7 +173,12 @@ func handleDomainsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "domains create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "domains create", + Transform: transform, + }) } func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -217,7 +221,12 @@ func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "domains update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "domains update", + Transform: transform, + }) } func handleDomainsList(ctx context.Context, cmd *cli.Command) error { @@ -252,7 +261,12 @@ func handleDomainsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "domains list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "domains list", + Transform: transform, + }) } func handleDomainsDelete(ctx context.Context, cmd *cli.Command) error { @@ -313,7 +327,12 @@ func handleDomainsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "domains get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "domains get", + Transform: transform, + }) } func handleDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/draft.go b/pkg/cmd/draft.go index b7b9ca3..1020791 100644 --- a/pkg/cmd/draft.go +++ b/pkg/cmd/draft.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -122,7 +121,12 @@ func handleDraftsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "drafts list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "drafts list", + Transform: transform, + }) } func handleDraftsGet(ctx context.Context, cmd *cli.Command) error { @@ -158,7 +162,12 @@ func handleDraftsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "drafts get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "drafts get", + Transform: transform, + }) } func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -203,5 +212,10 @@ func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "drafts get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "drafts get-attachment", + Transform: transform, + }) } diff --git a/pkg/cmd/inbox.go b/pkg/cmd/inbox.go index 68bb4ae..a6a58ba 100644 --- a/pkg/cmd/inbox.go +++ b/pkg/cmd/inbox.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -198,7 +197,12 @@ func handleInboxesCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes create", + Transform: transform, + }) } func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { @@ -241,7 +245,12 @@ func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes update", + Transform: transform, + }) } func handleInboxesList(ctx context.Context, cmd *cli.Command) error { @@ -276,7 +285,12 @@ func handleInboxesList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes list", + Transform: transform, + }) } func handleInboxesDelete(ctx context.Context, cmd *cli.Command) error { @@ -337,7 +351,12 @@ func handleInboxesGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes get", + Transform: transform, + }) } func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { @@ -380,5 +399,10 @@ func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes list-metrics", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes list-metrics", + Transform: transform, + }) } diff --git a/pkg/cmd/inboxapikey.go b/pkg/cmd/inboxapikey.go index 7a1b8f9..0df3a94 100644 --- a/pkg/cmd/inboxapikey.go +++ b/pkg/cmd/inboxapikey.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -303,7 +302,12 @@ func handleInboxesAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:api-keys create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:api-keys create", + Transform: transform, + }) } func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -346,7 +350,12 @@ func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:api-keys list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:api-keys list", + Transform: transform, + }) } func handleInboxesAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/inboxdraft.go b/pkg/cmd/inboxdraft.go index 514dfa1..bbf96f2 100644 --- a/pkg/cmd/inboxdraft.go +++ b/pkg/cmd/inboxdraft.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -363,7 +362,12 @@ func handleInboxesDraftsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts create", + Transform: transform, + }) } func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -408,7 +412,12 @@ func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts update", + Transform: transform, + }) } func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { @@ -451,7 +460,12 @@ func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts list", + Transform: transform, + }) } func handleInboxesDraftsDelete(ctx context.Context, cmd *cli.Command) error { @@ -530,7 +544,12 @@ func handleInboxesDraftsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts get", + Transform: transform, + }) } func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -576,7 +595,12 @@ func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) err format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts get-attachment", + Transform: transform, + }) } func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { @@ -621,5 +645,10 @@ func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:drafts send", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:drafts send", + Transform: transform, + }) } diff --git a/pkg/cmd/inboxlist.go b/pkg/cmd/inboxlist.go index 9e3fcef..004bb98 100644 --- a/pkg/cmd/inboxlist.go +++ b/pkg/cmd/inboxlist.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -187,7 +186,12 @@ func handleInboxesListsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:lists create", + Transform: transform, + }) } func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { @@ -233,7 +237,12 @@ func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:lists list", + Transform: transform, + }) } func handleInboxesListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -316,5 +325,10 @@ func handleInboxesListsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:lists get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:lists get", + Transform: transform, + }) } diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index 0360b6a..64ae35c 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -586,7 +585,12 @@ func handleInboxesMessagesUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages update", + Transform: transform, + }) } func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { @@ -629,7 +633,12 @@ func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages list", + Transform: transform, + }) } func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { @@ -674,7 +683,12 @@ func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages forward", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages forward", + Transform: transform, + }) } func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { @@ -719,7 +733,12 @@ func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages get", + Transform: transform, + }) } func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -765,7 +784,12 @@ func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) e format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages get-attachment", + Transform: transform, + }) } func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { @@ -810,7 +834,12 @@ func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages get-raw", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages get-raw", + Transform: transform, + }) } func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { @@ -855,7 +884,12 @@ func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages reply", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages reply", + Transform: transform, + }) } func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error { @@ -900,7 +934,12 @@ func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages reply-all", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages reply-all", + Transform: transform, + }) } func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { @@ -943,5 +982,10 @@ func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:messages send", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:messages send", + Transform: transform, + }) } diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index f46448c..72a8825 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -185,7 +184,12 @@ func handleInboxesThreadsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:threads list", + Transform: transform, + }) } func handleInboxesThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -264,7 +268,12 @@ func handleInboxesThreadsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:threads get", + Transform: transform, + }) } func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -310,5 +319,10 @@ func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) er format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "inboxes:threads get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "inboxes:threads get-attachment", + Transform: transform, + }) } diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 3a481ff..5084041 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -166,7 +165,12 @@ func handleListsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "lists create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "lists create", + Transform: transform, + }) } func handleListsList(ctx context.Context, cmd *cli.Command) error { @@ -211,7 +215,12 @@ func handleListsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "lists list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "lists list", + Transform: transform, + }) } func handleListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -292,5 +301,10 @@ func handleListsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "lists get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "lists get", + Transform: transform, + }) } diff --git a/pkg/cmd/metric.go b/pkg/cmd/metric.go index f85c0b5..7594261 100644 --- a/pkg/cmd/metric.go +++ b/pkg/cmd/metric.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -87,5 +86,10 @@ func handleMetricsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "metrics list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "metrics list", + Transform: transform, + }) } diff --git a/pkg/cmd/organization.go b/pkg/cmd/organization.go index 88a392c..26c9f41 100644 --- a/pkg/cmd/organization.go +++ b/pkg/cmd/organization.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-go" @@ -53,5 +52,10 @@ func handleOrganizationsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "organizations get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "organizations get", + Transform: transform, + }) } diff --git a/pkg/cmd/pod.go b/pkg/cmd/pod.go index fb7fba4..ba89712 100644 --- a/pkg/cmd/pod.go +++ b/pkg/cmd/pod.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -122,7 +121,12 @@ func handlePodsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods create", + Transform: transform, + }) } func handlePodsList(ctx context.Context, cmd *cli.Command) error { @@ -157,7 +161,12 @@ func handlePodsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods list", + Transform: transform, + }) } func handlePodsDelete(ctx context.Context, cmd *cli.Command) error { @@ -218,5 +227,10 @@ func handlePodsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods get", + Transform: transform, + }) } diff --git a/pkg/cmd/podapikey.go b/pkg/cmd/podapikey.go index 6853129..4b69467 100644 --- a/pkg/cmd/podapikey.go +++ b/pkg/cmd/podapikey.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -303,7 +302,12 @@ func handlePodsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:api-keys create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:api-keys create", + Transform: transform, + }) } func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { @@ -346,7 +350,12 @@ func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:api-keys list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:api-keys list", + Transform: transform, + }) } func handlePodsAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/poddomain.go b/pkg/cmd/poddomain.go index 28aa494..ff74137 100644 --- a/pkg/cmd/poddomain.go +++ b/pkg/cmd/poddomain.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -217,7 +216,12 @@ func handlePodsDomainsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:domains create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:domains create", + Transform: transform, + }) } func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { @@ -262,7 +266,12 @@ func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:domains update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:domains update", + Transform: transform, + }) } func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { @@ -305,7 +314,12 @@ func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:domains list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:domains list", + Transform: transform, + }) } func handlePodsDomainsDelete(ctx context.Context, cmd *cli.Command) error { @@ -384,7 +398,12 @@ func handlePodsDomainsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:domains get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:domains get", + Transform: transform, + }) } func handlePodsDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { diff --git a/pkg/cmd/poddraft.go b/pkg/cmd/poddraft.go index 5f204f2..477fd63 100644 --- a/pkg/cmd/poddraft.go +++ b/pkg/cmd/poddraft.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -145,7 +144,12 @@ func handlePodsDraftsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:drafts list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:drafts list", + Transform: transform, + }) } func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { @@ -190,7 +194,12 @@ func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:drafts get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:drafts get", + Transform: transform, + }) } func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -236,5 +245,10 @@ func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:drafts get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:drafts get-attachment", + Transform: transform, + }) } diff --git a/pkg/cmd/podinbox.go b/pkg/cmd/podinbox.go index 39436f8..19358ac 100644 --- a/pkg/cmd/podinbox.go +++ b/pkg/cmd/podinbox.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -186,7 +185,12 @@ func handlePodsInboxesCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:inboxes create", + Transform: transform, + }) } func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { @@ -231,7 +235,12 @@ func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:inboxes update", + Transform: transform, + }) } func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { @@ -274,7 +283,12 @@ func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:inboxes list", + Transform: transform, + }) } func handlePodsInboxesDelete(ctx context.Context, cmd *cli.Command) error { @@ -353,5 +367,10 @@ func handlePodsInboxesGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:inboxes get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:inboxes get", + Transform: transform, + }) } diff --git a/pkg/cmd/podlist.go b/pkg/cmd/podlist.go index 7eca84a..74c3782 100644 --- a/pkg/cmd/podlist.go +++ b/pkg/cmd/podlist.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -187,7 +186,12 @@ func handlePodsListsCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:lists create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:lists create", + Transform: transform, + }) } func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { @@ -233,7 +237,12 @@ func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:lists list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:lists list", + Transform: transform, + }) } func handlePodsListsDelete(ctx context.Context, cmd *cli.Command) error { @@ -316,5 +325,10 @@ func handlePodsListsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:lists get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:lists get", + Transform: transform, + }) } diff --git a/pkg/cmd/podmetric.go b/pkg/cmd/podmetric.go index 33109b5..3930e57 100644 --- a/pkg/cmd/podmetric.go +++ b/pkg/cmd/podmetric.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -100,5 +99,10 @@ func handlePodsMetricsQuery(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:metrics query", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:metrics query", + Transform: transform, + }) } diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index 811bfef..1638e2d 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -185,7 +184,12 @@ func handlePodsThreadsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:threads list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:threads list", + Transform: transform, + }) } func handlePodsThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -264,7 +268,12 @@ func handlePodsThreadsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:threads get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:threads get", + Transform: transform, + }) } func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -310,5 +319,10 @@ func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "pods:threads get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "pods:threads get-attachment", + Transform: transform, + }) } diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index 1007226..b4a49e7 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -157,7 +156,12 @@ func handleThreadsList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "threads list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "threads list", + Transform: transform, + }) } func handleThreadsDelete(ctx context.Context, cmd *cli.Command) error { @@ -225,7 +229,12 @@ func handleThreadsGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "threads get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "threads get", + Transform: transform, + }) } func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { @@ -270,5 +279,10 @@ func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "threads get-attachment", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "threads get-attachment", + Transform: transform, + }) } diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index 4c1b45b..02a0cb0 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -5,7 +5,6 @@ package cmd import ( "context" "fmt" - "os" "github.com/agentmail-to/agentmail-cli/internal/apiquery" "github.com/agentmail-to/agentmail-cli/internal/requestflag" @@ -174,7 +173,12 @@ func handleWebhooksCreate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "webhooks create", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "webhooks create", + Transform: transform, + }) } func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { @@ -217,7 +221,12 @@ func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "webhooks update", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "webhooks update", + Transform: transform, + }) } func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { @@ -252,7 +261,12 @@ func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "webhooks list", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "webhooks list", + Transform: transform, + }) } func handleWebhooksDelete(ctx context.Context, cmd *cli.Command) error { @@ -313,5 +327,10 @@ func handleWebhooksGet(ctx context.Context, cmd *cli.Command) error { format := cmd.Root().String("format") explicitFormat := cmd.Root().IsSet("format") transform := cmd.Root().String("transform") - return ShowJSON(os.Stdout, os.Stderr, "webhooks get", obj, format, explicitFormat, transform) + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + Title: "webhooks get", + Transform: transform, + }) } From 1da7c3edc342f6ef4d1aff1083d0b98e8aec47ad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 21:42:33 +0000 Subject: [PATCH 05/31] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d6b0c8a..957be15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-830c24d3ff39df5248fd06a0e32a64a57bdf6ed4f58bb33244cab98fa7c3476e.yml -openapi_spec_hash: c71d36752561924eb2e11bce3f93c32f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-e0a11b43915053701813adfcbf5bc7573d2a74f63b7abb8cfdedc9565ac3f134.yml +openapi_spec_hash: ec0c63b37bac5e4ef29bc2ca02e81203 config_hash: 8ab5eb1bfc282411f0283d386a319f23 From 0e6001439c676f9b793176e39417f69ff94d01ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 05:49:41 +0000 Subject: [PATCH 06/31] chore(ci): support manually triggering release workflow --- .github/workflows/publish-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ebb534a..81520dc 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,6 +10,7 @@ on: push: tags: - "v*" + workflow_dispatch: {} jobs: goreleaser: runs-on: ubuntu-latest From 65a86ee9ddb38368eebc5a472380d9d85b4fb6c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 05:50:59 +0000 Subject: [PATCH 07/31] feat(cli): send filename and content type when reading input from files --- pkg/cmd/flagoptions.go | 65 +++++++++++++++++++++++++++++++++++-- pkg/cmd/flagoptions_test.go | 59 ++++++++++++++++++++++++++++++--- 2 files changed, 117 insertions(+), 7 deletions(-) diff --git a/pkg/cmd/flagoptions.go b/pkg/cmd/flagoptions.go index 9eb5221..8ad5f59 100644 --- a/pkg/cmd/flagoptions.go +++ b/pkg/cmd/flagoptions.go @@ -7,9 +7,11 @@ import ( "fmt" "io" "maps" + "mime" "mime/multipart" "net/http" "os" + "path/filepath" "reflect" "strings" "unicode/utf8" @@ -36,7 +38,14 @@ const ( type FileEmbedStyle int const ( + // EmbedText reads referenced files fully into memory and substitutes the file's contents back into the + // value as a string. Binary files are base64-encoded. Used for JSON request bodies and for headers and + // query parameters, where the file contents need to be serialized inline. EmbedText FileEmbedStyle = iota + + // EmbedIOReader replaces file references with an io.Reader that streams the file's contents. Used for + // `multipart/form-data` and `application/octet-stream` request bodies, where files are uploaded as binary + // parts rather than embedded into a text value. EmbedIOReader ) @@ -142,6 +151,20 @@ func embedFilesValue(v reflect.Value, embedStyle FileEmbedStyle, stdin *onceStdi if s == "" { return v, nil } + if embedStyle == EmbedIOReader { + if isStdinPath(s) { + r, err := stdin.read() + if err != nil { + return v, err + } + return reflect.ValueOf(io.NopCloser(r)), nil + } + upload, err := openFileUpload(s) + if err != nil { + return v, err + } + return reflect.ValueOf(upload), nil + } if isStdinPath(s) { content, err := stdin.readAll() if err != nil { @@ -250,7 +273,7 @@ func embedFilesValue(v reflect.Value, embedStyle FileEmbedStyle, stdin *onceStdi return reflect.ValueOf(io.NopCloser(r)), nil } - file, err := os.Open(filename) + upload, err := openFileUpload(filename) if err != nil { if !expectsFile { // For strings that start with "@" and don't look like a filename, return the string @@ -258,7 +281,7 @@ func embedFilesValue(v reflect.Value, embedStyle FileEmbedStyle, stdin *onceStdi } return v, err } - return reflect.ValueOf(file), nil + return reflect.ValueOf(upload), nil } } return v, nil @@ -492,6 +515,44 @@ func flagOptions( // as a file path without needing the "@" prefix. type FilePathValue string +// fileUpload wraps an io.Reader with filename and content-type metadata for +// use as a multipart form part. The apiform encoder detects the Filename and +// ContentType methods and uses them to populate the Content-Disposition +// filename and the Content-Type header on the part. +type fileUpload struct { + io.Reader // apiform checks for reader and reads its contents during encode + filename string + contentType string +} + +func (f fileUpload) Filename() string { return f.filename } +func (f fileUpload) ContentType() string { return f.contentType } +func (f fileUpload) Close() error { + if c, ok := f.Reader.(io.Closer); ok { + return c.Close() + } + return nil +} + +// openFileUpload opens the file at path and returns a fileUpload whose filename +// is the path's basename and whose content type is derived from the file +// extension (falling back to application/octet-stream when unknown). +func openFileUpload(path string) (fileUpload, error) { + file, err := os.Open(path) + if err != nil { + return fileUpload{}, err + } + contentType := mime.TypeByExtension(filepath.Ext(path)) + if contentType == "" { + contentType = "application/octet-stream" + } + return fileUpload{ + Reader: file, + filename: filepath.Base(path), + contentType: contentType, + }, nil +} + // applyDataAliases rewrites keys in a body map based on flag `DataAliases` metadata. For top-level flags, // `{alias: value}` becomes `{canonical: value}`. For inner flags (those registered under an outer flag // via WithInnerFlags), the alias translation is also applied to the nested map under the outer flag's diff --git a/pkg/cmd/flagoptions_test.go b/pkg/cmd/flagoptions_test.go index 039b9ff..00734ca 100644 --- a/pkg/cmd/flagoptions_test.go +++ b/pkg/cmd/flagoptions_test.go @@ -8,7 +8,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -31,7 +30,7 @@ func TestIsUTF8TextFile(t *testing.T) { } for _, tt := range tests { - assert.Equal(t, tt.expected, isUTF8TextFile(tt.content)) + require.Equal(t, tt.expected, isUTF8TextFile(tt.content)) } } @@ -226,10 +225,10 @@ func TestEmbedFiles(t *testing.T) { got, err := embedFiles(tt.input, EmbedText, nil) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { require.NoError(t, err) - assert.Equal(t, tt.want, got) + require.Equal(t, tt.want, got) } }) @@ -238,7 +237,7 @@ func TestEmbedFiles(t *testing.T) { _, err := embedFiles(tt.input, EmbedIOReader, nil) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { require.NoError(t, err) } @@ -333,6 +332,56 @@ func TestEmbedFilesStdin(t *testing.T) { }) } +// TestEmbedFilesUploadMetadata verifies that EmbedIOReader mode wraps file readers with filename and +// content-type metadata so the multipart encoder populates `Content-Disposition` and `Content-Type` headers. +func TestEmbedFilesUploadMetadata(t *testing.T) { + t.Parallel() + + tmpDir := t.TempDir() + writeTestFile(t, tmpDir, "hello.txt", "hi") + writeTestFile(t, tmpDir, "page.html", "") + writeTestFile(t, tmpDir, "blob.bin", "\x00\x01") + + cases := []struct { + basename string + wantContentType string + }{ + {"hello.txt", "text/plain; charset=utf-8"}, + {"page.html", "text/html; charset=utf-8"}, + {"blob.bin", "application/octet-stream"}, + } + + for _, tc := range cases { + t.Run("AtPrefix_"+tc.basename, func(t *testing.T) { + t.Parallel() + + path := filepath.Join(tmpDir, tc.basename) + withEmbedded, err := embedFiles(map[string]any{"file": "@" + path}, EmbedIOReader, nil) + require.NoError(t, err) + + upload, ok := withEmbedded.(map[string]any)["file"].(fileUpload) + require.True(t, ok, "expected fileUpload, got %T", withEmbedded.(map[string]any)["file"]) + require.Equal(t, tc.basename, upload.Filename()) + require.Equal(t, upload.ContentType(), tc.wantContentType) + require.NoError(t, upload.Close()) + }) + + t.Run("FilePathValue_"+tc.basename, func(t *testing.T) { + t.Parallel() + + path := filepath.Join(tmpDir, tc.basename) + withEmbedded, err := embedFiles(map[string]any{"file": FilePathValue(path)}, EmbedIOReader, nil) + require.NoError(t, err) + + upload, ok := withEmbedded.(map[string]any)["file"].(fileUpload) + require.True(t, ok, "expected fileUpload, got %T", withEmbedded.(map[string]any)["file"]) + require.Equal(t, tc.basename, upload.Filename()) + require.Equal(t, upload.ContentType(), tc.wantContentType) + require.NoError(t, upload.Close()) + }) + } +} + func writeTestFile(t *testing.T, dir, filename, content string) { t.Helper() From f9df419dc3ba3b15a8a267db59207e81eea217f5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 05:52:51 +0000 Subject: [PATCH 08/31] feat(cli): add `--raw-output`/`-r` option to print raw (non-JSON) strings --- pkg/cmd/agent.go | 2 ++ pkg/cmd/apikey.go | 2 ++ pkg/cmd/cmd.go | 5 +++++ pkg/cmd/cmdutil.go | 14 ++++++++++---- pkg/cmd/cmdutil_test.go | 37 +++++++++++++++++++++++++++++++++---- pkg/cmd/domain.go | 4 ++++ pkg/cmd/draft.go | 3 +++ pkg/cmd/inbox.go | 5 +++++ pkg/cmd/inboxapikey.go | 2 ++ pkg/cmd/inboxdraft.go | 6 ++++++ pkg/cmd/inboxlist.go | 3 +++ pkg/cmd/inboxmessage.go | 9 +++++++++ pkg/cmd/inboxthread.go | 3 +++ pkg/cmd/list.go | 3 +++ pkg/cmd/metric.go | 1 + pkg/cmd/organization.go | 1 + pkg/cmd/pod.go | 3 +++ pkg/cmd/podapikey.go | 2 ++ pkg/cmd/poddomain.go | 4 ++++ pkg/cmd/poddraft.go | 3 +++ pkg/cmd/podinbox.go | 4 ++++ pkg/cmd/podlist.go | 3 +++ pkg/cmd/podmetric.go | 1 + pkg/cmd/podthread.go | 3 +++ pkg/cmd/thread.go | 3 +++ pkg/cmd/webhook.go | 4 ++++ 26 files changed, 122 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/agent.go b/pkg/cmd/agent.go index 9b2cbea..75f271a 100644 --- a/pkg/cmd/agent.go +++ b/pkg/cmd/agent.go @@ -87,6 +87,7 @@ func handleAgentSignUp(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "agent sign-up", Transform: transform, }) @@ -127,6 +128,7 @@ func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "agent verify", Transform: transform, }) diff --git a/pkg/cmd/apikey.go b/pkg/cmd/apikey.go index 4800ce7..0757427 100644 --- a/pkg/cmd/apikey.go +++ b/pkg/cmd/apikey.go @@ -287,6 +287,7 @@ func handleAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "api-keys create", Transform: transform, }) @@ -327,6 +328,7 @@ func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "api-keys list", Transform: transform, }) diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index bede572..d89cb34 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -73,6 +73,11 @@ func init() { Name: "transform-error", Usage: "The GJSON transformation for errors.", }, + &cli.BoolFlag{ + Name: "raw-output", + Aliases: []string{"r"}, + Usage: "If the result is a string, print it without JSON quotes. This can be useful for making output transforms talk to non-JSON-based systems.", + }, &requestflag.Flag[string]{ Name: "api-key", Sources: cli.EnvVars("AGENTMAIL_API_KEY"), diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index d15bae7..4e9de4e 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -323,16 +323,21 @@ func shouldUseColors(w io.Writer) bool { return isTerminal(w) } -func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format string, transform string) ([]byte, error) { +func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format string, transform string, rawOutput bool) ([]byte, error) { if transform != "" { transformed := res.Get(transform) if transformed.Exists() { res = transformed } } + // Modeled after `jq -r` (`--raw-output`): if the result is a string, print it without JSON quotes so that + // it's easier to pipe into other programs. + if rawOutput && res.Type == gjson.String { + return []byte(res.Str + "\n"), nil + } switch strings.ToLower(format) { case "auto": - return formatJSON(expectedOutput, title, res, "json", "") + return formatJSON(expectedOutput, title, res, "json", "", rawOutput) case "pretty": return []byte(jsonview.RenderJSON(title, res) + "\n"), nil case "json": @@ -372,6 +377,7 @@ const warningExploreNotSupported = "Warning: Output format 'explore' not support type ShowJSONOpts struct { ExplicitFormat bool // true if the user explicitly passed --format Format string // output format (auto, explore, json, jsonl, pretty, raw, yaml) + RawOutput bool // like jq -r: print strings without JSON quotes Stderr io.Writer // stderr for warnings; injectable for testing; defaults to os.Stderr Stdout *os.File // stdout (or pager); injectable for testing; defaults to os.Stdout Title string // display title @@ -414,7 +420,7 @@ func ShowJSON(res gjson.Result, opts ShowJSONOpts) error { } return jsonview.ExploreJSON(opts.Title, res) default: - bytes, err := formatJSON(opts.Stdout, opts.Title, res, opts.Format, opts.Transform) + bytes, err := formatJSON(opts.Stdout, opts.Title, res, opts.Format, opts.Transform, opts.RawOutput) if err != nil { return err } @@ -471,7 +477,7 @@ func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, op } obj = gjson.ParseBytes(jsonData) } - json, err := formatJSON(opts.Stdout, opts.Title, obj, format, opts.Transform) + json, err := formatJSON(opts.Stdout, opts.Title, obj, format, opts.Transform, opts.RawOutput) if err != nil { return err } diff --git a/pkg/cmd/cmdutil_test.go b/pkg/cmd/cmdutil_test.go index a5799aa..cbfc652 100644 --- a/pkg/cmd/cmdutil_test.go +++ b/pkg/cmd/cmdutil_test.go @@ -159,7 +159,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123","name":"test"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "id") + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "id", false) require.NoError(t, err) require.Equal(t, `"abc123"`+"\n", string(formatted)) }) @@ -168,7 +168,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123","name":"test"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "") + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "", false) require.NoError(t, err) require.Equal(t, `{"id":"abc123","name":"test"}`+"\n", string(formatted)) }) @@ -177,7 +177,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"data":{"items":[1,2,3]}}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "data.items") + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "data.items", false) require.NoError(t, err) require.Equal(t, "[1,2,3]\n", string(formatted)) }) @@ -186,11 +186,40 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "missing") + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "missing", false) require.NoError(t, err) // Transform path doesn't exist, so original result is returned require.Equal(t, `{"id":"abc123"}`+"\n", string(formatted)) }) + + t.Run("RawOutputString", func(t *testing.T) { + t.Parallel() + + res := gjson.Parse(`{"id":"abc123","name":"test"}`) + formatted, err := formatJSON(os.Stdout, "test", res, "json", "id", true) + require.NoError(t, err) + require.Equal(t, "abc123\n", string(formatted)) + }) + + t.Run("RawOutputNonString", func(t *testing.T) { + t.Parallel() + + // --raw-output has no effect on non-string values + res := gjson.Parse(`{"count":42}`) + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "count", true) + require.NoError(t, err) + require.Equal(t, "42\n", string(formatted)) + }) + + t.Run("RawOutputObject", func(t *testing.T) { + t.Parallel() + + // --raw-output has no effect on objects + res := gjson.Parse(`{"nested":{"a":1}}`) + formatted, err := formatJSON(os.Stdout, "test", res, "raw", "nested", true) + require.NoError(t, err) + require.Equal(t, `{"a":1}`+"\n", string(formatted)) + }) } func TestShowJSONIterator(t *testing.T) { diff --git a/pkg/cmd/domain.go b/pkg/cmd/domain.go index 84ff5ca..facdb1a 100644 --- a/pkg/cmd/domain.go +++ b/pkg/cmd/domain.go @@ -176,6 +176,7 @@ func handleDomainsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "domains create", Transform: transform, }) @@ -224,6 +225,7 @@ func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "domains update", Transform: transform, }) @@ -264,6 +266,7 @@ func handleDomainsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "domains list", Transform: transform, }) @@ -330,6 +333,7 @@ func handleDomainsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "domains get", Transform: transform, }) diff --git a/pkg/cmd/draft.go b/pkg/cmd/draft.go index 1020791..0b5a8b9 100644 --- a/pkg/cmd/draft.go +++ b/pkg/cmd/draft.go @@ -124,6 +124,7 @@ func handleDraftsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "drafts list", Transform: transform, }) @@ -165,6 +166,7 @@ func handleDraftsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "drafts get", Transform: transform, }) @@ -215,6 +217,7 @@ func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "drafts get-attachment", Transform: transform, }) diff --git a/pkg/cmd/inbox.go b/pkg/cmd/inbox.go index a6a58ba..f6b2dd1 100644 --- a/pkg/cmd/inbox.go +++ b/pkg/cmd/inbox.go @@ -200,6 +200,7 @@ func handleInboxesCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes create", Transform: transform, }) @@ -248,6 +249,7 @@ func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes update", Transform: transform, }) @@ -288,6 +290,7 @@ func handleInboxesList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes list", Transform: transform, }) @@ -354,6 +357,7 @@ func handleInboxesGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes get", Transform: transform, }) @@ -402,6 +406,7 @@ func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes list-metrics", Transform: transform, }) diff --git a/pkg/cmd/inboxapikey.go b/pkg/cmd/inboxapikey.go index 0df3a94..a59e810 100644 --- a/pkg/cmd/inboxapikey.go +++ b/pkg/cmd/inboxapikey.go @@ -305,6 +305,7 @@ func handleInboxesAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:api-keys create", Transform: transform, }) @@ -353,6 +354,7 @@ func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:api-keys list", Transform: transform, }) diff --git a/pkg/cmd/inboxdraft.go b/pkg/cmd/inboxdraft.go index bbf96f2..0f11108 100644 --- a/pkg/cmd/inboxdraft.go +++ b/pkg/cmd/inboxdraft.go @@ -365,6 +365,7 @@ func handleInboxesDraftsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts create", Transform: transform, }) @@ -415,6 +416,7 @@ func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts update", Transform: transform, }) @@ -463,6 +465,7 @@ func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts list", Transform: transform, }) @@ -547,6 +550,7 @@ func handleInboxesDraftsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts get", Transform: transform, }) @@ -598,6 +602,7 @@ func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) err return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts get-attachment", Transform: transform, }) @@ -648,6 +653,7 @@ func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:drafts send", Transform: transform, }) diff --git a/pkg/cmd/inboxlist.go b/pkg/cmd/inboxlist.go index 004bb98..c0517a1 100644 --- a/pkg/cmd/inboxlist.go +++ b/pkg/cmd/inboxlist.go @@ -189,6 +189,7 @@ func handleInboxesListsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:lists create", Transform: transform, }) @@ -240,6 +241,7 @@ func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:lists list", Transform: transform, }) @@ -328,6 +330,7 @@ func handleInboxesListsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:lists get", Transform: transform, }) diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index 64ae35c..e1b480c 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -588,6 +588,7 @@ func handleInboxesMessagesUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages update", Transform: transform, }) @@ -636,6 +637,7 @@ func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages list", Transform: transform, }) @@ -686,6 +688,7 @@ func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages forward", Transform: transform, }) @@ -736,6 +739,7 @@ func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages get", Transform: transform, }) @@ -787,6 +791,7 @@ func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) e return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages get-attachment", Transform: transform, }) @@ -837,6 +842,7 @@ func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages get-raw", Transform: transform, }) @@ -887,6 +893,7 @@ func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages reply", Transform: transform, }) @@ -937,6 +944,7 @@ func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages reply-all", Transform: transform, }) @@ -985,6 +993,7 @@ func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:messages send", Transform: transform, }) diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index 72a8825..59738c6 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -187,6 +187,7 @@ func handleInboxesThreadsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:threads list", Transform: transform, }) @@ -271,6 +272,7 @@ func handleInboxesThreadsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:threads get", Transform: transform, }) @@ -322,6 +324,7 @@ func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) er return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "inboxes:threads get-attachment", Transform: transform, }) diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 5084041..d269bea 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -168,6 +168,7 @@ func handleListsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "lists create", Transform: transform, }) @@ -218,6 +219,7 @@ func handleListsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "lists list", Transform: transform, }) @@ -304,6 +306,7 @@ func handleListsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "lists get", Transform: transform, }) diff --git a/pkg/cmd/metric.go b/pkg/cmd/metric.go index 7594261..380516a 100644 --- a/pkg/cmd/metric.go +++ b/pkg/cmd/metric.go @@ -89,6 +89,7 @@ func handleMetricsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "metrics list", Transform: transform, }) diff --git a/pkg/cmd/organization.go b/pkg/cmd/organization.go index 26c9f41..1af9601 100644 --- a/pkg/cmd/organization.go +++ b/pkg/cmd/organization.go @@ -55,6 +55,7 @@ func handleOrganizationsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "organizations get", Transform: transform, }) diff --git a/pkg/cmd/pod.go b/pkg/cmd/pod.go index ba89712..c6ac651 100644 --- a/pkg/cmd/pod.go +++ b/pkg/cmd/pod.go @@ -124,6 +124,7 @@ func handlePodsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods create", Transform: transform, }) @@ -164,6 +165,7 @@ func handlePodsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods list", Transform: transform, }) @@ -230,6 +232,7 @@ func handlePodsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods get", Transform: transform, }) diff --git a/pkg/cmd/podapikey.go b/pkg/cmd/podapikey.go index 4b69467..46d0731 100644 --- a/pkg/cmd/podapikey.go +++ b/pkg/cmd/podapikey.go @@ -305,6 +305,7 @@ func handlePodsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:api-keys create", Transform: transform, }) @@ -353,6 +354,7 @@ func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:api-keys list", Transform: transform, }) diff --git a/pkg/cmd/poddomain.go b/pkg/cmd/poddomain.go index ff74137..fd25dad 100644 --- a/pkg/cmd/poddomain.go +++ b/pkg/cmd/poddomain.go @@ -219,6 +219,7 @@ func handlePodsDomainsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:domains create", Transform: transform, }) @@ -269,6 +270,7 @@ func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:domains update", Transform: transform, }) @@ -317,6 +319,7 @@ func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:domains list", Transform: transform, }) @@ -401,6 +404,7 @@ func handlePodsDomainsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:domains get", Transform: transform, }) diff --git a/pkg/cmd/poddraft.go b/pkg/cmd/poddraft.go index 477fd63..c989561 100644 --- a/pkg/cmd/poddraft.go +++ b/pkg/cmd/poddraft.go @@ -147,6 +147,7 @@ func handlePodsDraftsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:drafts list", Transform: transform, }) @@ -197,6 +198,7 @@ func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:drafts get", Transform: transform, }) @@ -248,6 +250,7 @@ func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:drafts get-attachment", Transform: transform, }) diff --git a/pkg/cmd/podinbox.go b/pkg/cmd/podinbox.go index 19358ac..c004633 100644 --- a/pkg/cmd/podinbox.go +++ b/pkg/cmd/podinbox.go @@ -188,6 +188,7 @@ func handlePodsInboxesCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:inboxes create", Transform: transform, }) @@ -238,6 +239,7 @@ func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:inboxes update", Transform: transform, }) @@ -286,6 +288,7 @@ func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:inboxes list", Transform: transform, }) @@ -370,6 +373,7 @@ func handlePodsInboxesGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:inboxes get", Transform: transform, }) diff --git a/pkg/cmd/podlist.go b/pkg/cmd/podlist.go index 74c3782..7a97f1e 100644 --- a/pkg/cmd/podlist.go +++ b/pkg/cmd/podlist.go @@ -189,6 +189,7 @@ func handlePodsListsCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:lists create", Transform: transform, }) @@ -240,6 +241,7 @@ func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:lists list", Transform: transform, }) @@ -328,6 +330,7 @@ func handlePodsListsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:lists get", Transform: transform, }) diff --git a/pkg/cmd/podmetric.go b/pkg/cmd/podmetric.go index 3930e57..56882e9 100644 --- a/pkg/cmd/podmetric.go +++ b/pkg/cmd/podmetric.go @@ -102,6 +102,7 @@ func handlePodsMetricsQuery(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:metrics query", Transform: transform, }) diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index 1638e2d..9858421 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -187,6 +187,7 @@ func handlePodsThreadsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:threads list", Transform: transform, }) @@ -271,6 +272,7 @@ func handlePodsThreadsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:threads get", Transform: transform, }) @@ -322,6 +324,7 @@ func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "pods:threads get-attachment", Transform: transform, }) diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index b4a49e7..96dd42b 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -159,6 +159,7 @@ func handleThreadsList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "threads list", Transform: transform, }) @@ -232,6 +233,7 @@ func handleThreadsGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "threads get", Transform: transform, }) @@ -282,6 +284,7 @@ func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "threads get-attachment", Transform: transform, }) diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index 02a0cb0..99254d4 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -176,6 +176,7 @@ func handleWebhooksCreate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "webhooks create", Transform: transform, }) @@ -224,6 +225,7 @@ func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "webhooks update", Transform: transform, }) @@ -264,6 +266,7 @@ func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "webhooks list", Transform: transform, }) @@ -330,6 +333,7 @@ func handleWebhooksGet(ctx context.Context, cmd *cli.Command) error { return ShowJSON(obj, ShowJSONOpts{ ExplicitFormat: explicitFormat, Format: format, + RawOutput: cmd.Root().Bool("raw-output"), Title: "webhooks get", Transform: transform, }) From 0e944460e3f00ab8cb1040bb18e0380bb3574dbe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 05:57:45 +0000 Subject: [PATCH 09/31] chore(cli): use `ShowJSONOpts` as argument to `formatJSON` instead of many positionals --- pkg/cmd/cmdutil.go | 54 ++++++++++++++++++++--------------------- pkg/cmd/cmdutil_test.go | 14 +++++------ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pkg/cmd/cmdutil.go b/pkg/cmd/cmdutil.go index 4e9de4e..644b807 100644 --- a/pkg/cmd/cmdutil.go +++ b/pkg/cmd/cmdutil.go @@ -323,26 +323,29 @@ func shouldUseColors(w io.Writer) bool { return isTerminal(w) } -func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format string, transform string, rawOutput bool) ([]byte, error) { - if transform != "" { - transformed := res.Get(transform) +func formatJSON(res gjson.Result, opts ShowJSONOpts) ([]byte, error) { + if opts.Transform != "" { + transformed := res.Get(opts.Transform) if transformed.Exists() { res = transformed } } // Modeled after `jq -r` (`--raw-output`): if the result is a string, print it without JSON quotes so that // it's easier to pipe into other programs. - if rawOutput && res.Type == gjson.String { + if opts.RawOutput && res.Type == gjson.String { return []byte(res.Str + "\n"), nil } - switch strings.ToLower(format) { + switch strings.ToLower(opts.Format) { case "auto": - return formatJSON(expectedOutput, title, res, "json", "", rawOutput) + autoOpts := opts + autoOpts.Format = "json" + autoOpts.Transform = "" + return formatJSON(res, autoOpts) case "pretty": - return []byte(jsonview.RenderJSON(title, res) + "\n"), nil + return []byte(jsonview.RenderJSON(opts.Title, res) + "\n"), nil case "json": prettyJSON := pretty.Pretty([]byte(res.Raw)) - if shouldUseColors(expectedOutput) { + if shouldUseColors(opts.Stdout) { return pretty.Color(prettyJSON, pretty.TerminalStyle), nil } else { return prettyJSON, nil @@ -350,7 +353,7 @@ func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format case "jsonl": // @ugly is gjson syntax for "no whitespace", so it fits on one line oneLineJSON := res.Get("@ugly").Raw - if shouldUseColors(expectedOutput) { + if shouldUseColors(opts.Stdout) { bytes := append(pretty.Color([]byte(oneLineJSON), pretty.TerminalStyle), '\n') return bytes, nil } else { @@ -364,10 +367,10 @@ func formatJSON(expectedOutput *os.File, title string, res gjson.Result, format if err := json2yaml.Convert(&yaml, input); err != nil { return nil, err } - _, err := expectedOutput.Write([]byte(yaml.String())) + _, err := opts.Stdout.Write([]byte(yaml.String())) return nil, err default: - return nil, fmt.Errorf("Invalid format: %s, valid formats are: %s", format, strings.Join(OutputFormats, ", ")) + return nil, fmt.Errorf("Invalid format: %s, valid formats are: %s", opts.Format, strings.Join(OutputFormats, ", ")) } } @@ -397,18 +400,11 @@ func (o *ShowJSONOpts) setDefaults() { func ShowJSON(res gjson.Result, opts ShowJSONOpts) error { opts.setDefaults() - if opts.Transform != "" { - transformed := res.Get(opts.Transform) - if transformed.Exists() { - res = transformed - } - } - switch strings.ToLower(opts.Format) { case "auto": - jsonOpts := opts - jsonOpts.Format = "json" - return ShowJSON(res, jsonOpts) + autoOpts := opts + autoOpts.Format = "json" + return ShowJSON(res, autoOpts) case "explore": if !isTerminal(opts.Stdout) { if opts.ExplicitFormat { @@ -418,9 +414,15 @@ func ShowJSON(res gjson.Result, opts ShowJSONOpts) error { jsonOpts.Format = "json" return ShowJSON(res, jsonOpts) } + if opts.Transform != "" { + transformed := res.Get(opts.Transform) + if transformed.Exists() { + res = transformed + } + } return jsonview.ExploreJSON(opts.Title, res) default: - bytes, err := formatJSON(opts.Stdout, opts.Title, res, opts.Format, opts.Transform, opts.RawOutput) + bytes, err := formatJSON(res, opts) if err != nil { return err } @@ -443,15 +445,14 @@ type hasRawJSON interface { func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, opts ShowJSONOpts) error { opts.setDefaults() - format := opts.Format - if format == "explore" { + if opts.Format == "explore" { if isTerminal(opts.Stdout) { return jsonview.ExploreJSONStream(opts.Title, iter) } if opts.ExplicitFormat { fmt.Fprint(opts.Stderr, warningExploreNotSupported) } - format = "json" + opts.Format = "json" } terminalWidth, terminalHeight, err := term.GetSize(os.Stdout.Fd()) @@ -477,7 +478,7 @@ func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, op } obj = gjson.ParseBytes(jsonData) } - json, err := formatJSON(opts.Stdout, opts.Title, obj, format, opts.Transform, opts.RawOutput) + json, err := formatJSON(obj, opts) if err != nil { return err } @@ -509,7 +510,6 @@ func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, op } pagerOpts := opts - pagerOpts.Format = format pagerOpts.Stdout = pager for iter.Next() { diff --git a/pkg/cmd/cmdutil_test.go b/pkg/cmd/cmdutil_test.go index cbfc652..2388ce6 100644 --- a/pkg/cmd/cmdutil_test.go +++ b/pkg/cmd/cmdutil_test.go @@ -159,7 +159,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123","name":"test"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "id", false) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout, Transform: "id"}) require.NoError(t, err) require.Equal(t, `"abc123"`+"\n", string(formatted)) }) @@ -168,7 +168,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123","name":"test"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "", false) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout}) require.NoError(t, err) require.Equal(t, `{"id":"abc123","name":"test"}`+"\n", string(formatted)) }) @@ -177,7 +177,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"data":{"items":[1,2,3]}}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "data.items", false) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout, Transform: "data.items"}) require.NoError(t, err) require.Equal(t, "[1,2,3]\n", string(formatted)) }) @@ -186,7 +186,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "missing", false) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout, Transform: "missing"}) require.NoError(t, err) // Transform path doesn't exist, so original result is returned require.Equal(t, `{"id":"abc123"}`+"\n", string(formatted)) @@ -196,7 +196,7 @@ func TestFormatJSON(t *testing.T) { t.Parallel() res := gjson.Parse(`{"id":"abc123","name":"test"}`) - formatted, err := formatJSON(os.Stdout, "test", res, "json", "id", true) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "json", Stdout: os.Stdout, Transform: "id", RawOutput: true}) require.NoError(t, err) require.Equal(t, "abc123\n", string(formatted)) }) @@ -206,7 +206,7 @@ func TestFormatJSON(t *testing.T) { // --raw-output has no effect on non-string values res := gjson.Parse(`{"count":42}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "count", true) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout, Transform: "count", RawOutput: true}) require.NoError(t, err) require.Equal(t, "42\n", string(formatted)) }) @@ -216,7 +216,7 @@ func TestFormatJSON(t *testing.T) { // --raw-output has no effect on objects res := gjson.Parse(`{"nested":{"a":1}}`) - formatted, err := formatJSON(os.Stdout, "test", res, "raw", "nested", true) + formatted, err := formatJSON(res, ShowJSONOpts{Format: "raw", Stdout: os.Stdout, Transform: "nested", RawOutput: true}) require.NoError(t, err) require.Equal(t, `{"a":1}`+"\n", string(formatted)) }) From 8b39e720cbe7e3c2c150bd7f2a563dd0feb298bf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 03:20:34 +0000 Subject: [PATCH 10/31] chore(internal): more robust bootstrap script --- scripts/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bootstrap b/scripts/bootstrap index 9ebb7d3..bbc786d 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response From c7f1282aabb0958db3b8dd601bdca796e5dc0f57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 02:50:11 +0000 Subject: [PATCH 11/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 81083cd..aea6acd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.8.0 + github.com/agentmail-to/agentmail-go v0.8.1 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 1089e67..66abdfe 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.8.0 h1:7Ek7UHIO0U2rrN6ib2gL1/W3LEkHdQfvQsHu0j3T+CQ= -github.com/agentmail-to/agentmail-go v0.8.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.8.1 h1:Te5F4q4E1JM1hgqPXm5wuWneEi2Adfpoei73iTj59EE= +github.com/agentmail-to/agentmail-go v0.8.1/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From 271e6ab44f3633a8c6c54323d7e1ef809ff9a788 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 19:36:02 +0000 Subject: [PATCH 12/31] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 957be15..ba2223a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-e0a11b43915053701813adfcbf5bc7573d2a74f63b7abb8cfdedc9565ac3f134.yml -openapi_spec_hash: ec0c63b37bac5e4ef29bc2ca02e81203 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-18101510657cc51b6f072219c469a002a6c92e2ef6d13008be105510845a832f.yml +openapi_spec_hash: bee4395e55747c75bfe3799ac6abf061 config_hash: 8ab5eb1bfc282411f0283d386a319f23 From 5b36c5391637ffda46b95c9095acda6f6be532e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 04:30:10 +0000 Subject: [PATCH 13/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index aea6acd..ee3b42b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.8.1 + github.com/agentmail-to/agentmail-go v0.9.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 66abdfe..1db991a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.8.1 h1:Te5F4q4E1JM1hgqPXm5wuWneEi2Adfpoei73iTj59EE= -github.com/agentmail-to/agentmail-go v0.8.1/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.9.0 h1:HSj60k0F9EvAmFLAdxVcddnUPx9F6wnM5EHVuRqtdkI= +github.com/agentmail-to/agentmail-go v0.9.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From 3a2b15dcf2210d33a59c9483c2e8bd336e78499c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 21:29:08 +0000 Subject: [PATCH 14/31] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ba2223a..cbd6104 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-18101510657cc51b6f072219c469a002a6c92e2ef6d13008be105510845a832f.yml -openapi_spec_hash: bee4395e55747c75bfe3799ac6abf061 +openapi_spec_hash: 485c40cab6b7ae69327ddc44a2ff82c9 config_hash: 8ab5eb1bfc282411f0283d386a319f23 From 062570454c9d38f42ce8690e6b20777b61fc0c70 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:05:37 +0000 Subject: [PATCH 15/31] ci: pin trigger-release-please github action --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee3b42b..fec3e09 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.9.0 + github.com/agentmail-to/agentmail-go v0.10.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 1db991a..d7930d9 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.9.0 h1:HSj60k0F9EvAmFLAdxVcddnUPx9F6wnM5EHVuRqtdkI= -github.com/agentmail-to/agentmail-go v0.9.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.10.0 h1:seHlvGOojKTO+mkdQLULm1G9NTQNh+sdPjXTySheQQE= +github.com/agentmail-to/agentmail-go v0.10.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From 1b982f78a9d150901b940791d7bc05fe1a396e49 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:10:43 +0000 Subject: [PATCH 16/31] fix(cli): correctly load zsh autocompletion --- .../autocomplete/shellscripts/zsh_autocomplete.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/autocomplete/shellscripts/zsh_autocomplete.zsh b/internal/autocomplete/shellscripts/zsh_autocomplete.zsh index 4d4bdcd..d937171 100644 --- a/internal/autocomplete/shellscripts/zsh_autocomplete.zsh +++ b/internal/autocomplete/shellscripts/zsh_autocomplete.zsh @@ -1,5 +1,4 @@ -#!/bin/zsh -compdef ____APPNAME___zsh_autocomplete __APPNAME__ +#compdef __APPNAME__ ____APPNAME___zsh_autocomplete() { @@ -44,3 +43,14 @@ ____APPNAME___zsh_autocomplete() { ;; esac } + +# When installed in fpath (e.g., via Homebrew's zsh_completion stanza), this file +# is autoloaded as the function ___APPNAME__ and its body becomes that function's +# body. Detect that case via funcstack and dispatch to the completion function. +# When sourced (e.g., `source <(__APPNAME__ @completion zsh)`), register the +# function with compdef instead. +if [[ "${funcstack[1]}" = "___APPNAME__" ]]; then + ____APPNAME___zsh_autocomplete "$@" +else + compdef ____APPNAME___zsh_autocomplete __APPNAME__ +fi From c6d3d0faba7569980c2f7824f335ee4bdea88e72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:16:04 +0000 Subject: [PATCH 17/31] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cbd6104..2cd935c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail%2Fagentmail-18101510657cc51b6f072219c469a002a6c92e2ef6d13008be105510845a832f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-c97dd45dc91d256d4a19c2d7ca44cc45acdc7f4c6e30a9e3ffb7f70d052e404e.yml openapi_spec_hash: 485c40cab6b7ae69327ddc44a2ff82c9 config_hash: 8ab5eb1bfc282411f0283d386a319f23 From f105a97104a8e6be911e6419733d9c7628577d84 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:18:27 +0000 Subject: [PATCH 18/31] fix: flags for nullable body scalar fields are strictly typed --- internal/requestflag/innerflag.go | 16 +- internal/requestflag/requestflag.go | 128 +++++++++- internal/requestflag/requestflag_test.go | 234 ++++++++++++++++++ pkg/cmd/apikey.go | 78 +++--- pkg/cmd/domain.go | 8 +- pkg/cmd/draft.go | 6 +- pkg/cmd/inbox.go | 20 +- pkg/cmd/inboxapikey.go | 76 +++--- pkg/cmd/inboxdraft.go | 86 +++---- pkg/cmd/inboxlist.go | 6 +- pkg/cmd/inboxmessage.go | 290 ++++++++++++----------- pkg/cmd/inboxthread.go | 14 +- pkg/cmd/list.go | 6 +- pkg/cmd/metric.go | 6 +- pkg/cmd/pod.go | 10 +- pkg/cmd/podapikey.go | 76 +++--- pkg/cmd/poddomain.go | 8 +- pkg/cmd/poddraft.go | 6 +- pkg/cmd/podinbox.go | 14 +- pkg/cmd/podlist.go | 6 +- pkg/cmd/podmetric.go | 6 +- pkg/cmd/podthread.go | 14 +- pkg/cmd/thread.go | 14 +- pkg/cmd/webhook.go | 8 +- 24 files changed, 768 insertions(+), 368 deletions(-) diff --git a/internal/requestflag/innerflag.go b/internal/requestflag/innerflag.go index eeeb8bc..528915f 100644 --- a/internal/requestflag/innerflag.go +++ b/internal/requestflag/innerflag.go @@ -14,7 +14,8 @@ import ( type InnerFlag[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | - string | float64 | int64 | bool, + string | float64 | int64 | bool | + *string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue, ] struct { Name string // name of the flag DefaultText string // default text of the flag for usage purposes @@ -25,6 +26,12 @@ type InnerFlag[ OuterFlag cli.Flag // The flag on which this inner flag will set values InnerField string // The inner field which this flag will set DataAliases []string // alternate names recognized in YAML values passed as the outer flag + + // OuterIsArrayOfObjects tells an untyped outer flag (Flag[any], used for nullable + // complex schemas) to seed its underlying value as []map[string]any rather than + // map[string]any before SetInnerField runs. The hint is ignored for typed outer + // flags whose zero value already carries a dispatchable reflect.Kind. + OuterIsArrayOfObjects bool } // GetDataAliases returns the aliases recognized when parsing inner field keys from piped or flag YAML. @@ -76,6 +83,10 @@ func (f *InnerFlag[T]) Set(name string, rawVal string) error { } } + if seeder, ok := f.OuterFlag.(InnerFieldSeeder); ok { + seeder.SeedInnerCollection(f.OuterIsArrayOfObjects) + } + if settableInnerField, ok := f.OuterFlag.(SettableInnerField); ok { settableInnerField.SetInnerField(f.InnerField, parsedValue) } else { @@ -136,6 +147,9 @@ func (f *InnerFlag[T]) TypeName() string { if ty == nil { return "" } + if ty.Kind() == reflect.Pointer { + ty = ty.Elem() + } // Get base type name with special handling for built-in types getTypeName := func(t reflect.Type) string { diff --git a/internal/requestflag/requestflag.go b/internal/requestflag/requestflag.go index bfaf064..54c2509 100644 --- a/internal/requestflag/requestflag.go +++ b/internal/requestflag/requestflag.go @@ -15,10 +15,15 @@ import ( // Flag [T] is a generic flag base which can be used to implement the most // common interfaces used by urfave/cli. Additionally, it allows specifying // where in an HTTP request the flag values should be placed (e.g. query, body, etc.). +// +// Pointer-to-primitive type parameters (e.g. *string) are used for flags whose underlying +// schema is nullable. They give flags a tri-state: unset (excluded from the request), +// set to the literal "null" (nil pointer → JSON null), or set to a value (*v → JSON value). type Flag[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | - string | float64 | int64 | bool, + string | float64 | int64 | bool | + *string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue, ] struct { Name string // name of the flag Category string // category of the flag, if any @@ -341,6 +346,11 @@ func (f *Flag[T]) TypeName() string { if ty == nil { return "" } + // Deref pointer-typed flags so --help surfaces the pointee kind (e.g. "string"), not + // Go's pointer syntax. + if ty.Kind() == reflect.Pointer { + ty = ty.Elem() + } // Get base type name with special handling for built-in types getTypeName := func(t reflect.Type) string { @@ -396,6 +406,8 @@ func (f *Flag[T]) IsMultiValueFlag() bool { } func (f *Flag[T]) IsBoolFlag() bool { + // Flag[*bool] is deliberately not treated as a bool flag — the pointer form needs an + // explicit value (`--foo true`, `--foo null`) to disambiguate the tri-state. _, isBool := any(f.Default).(bool) return isBool } @@ -419,7 +431,8 @@ func (f Flag[T]) IsLocal() bool { type cliValue[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | string | - float64 | int64 | bool, + float64 | int64 | bool | + *string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue, ] struct { value T } @@ -429,12 +442,27 @@ type cliValue[ func parseCLIArg[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | string | - float64 | int64 | bool, + float64 | int64 | bool | + *string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue, ](value string) (T, error) { var parsedValue any var err error var empty T + + if value == "null" { + switch any(empty).(type) { + // Pointer-to-primitive: explicit nil gives the tri-state its "null" state + // (unset / null / value). Without this, numeric flags would fail to parse + // "null" and string flags would accept the literal word as a raw value. + case *string, *int64, *float64, *bool, *DateValue, *DateTimeValue, *TimeValue: + return empty, nil + // Maps marshal nil as JSON null natively; short-circuit avoids a YAML round-trip. + case map[string]any: + return empty, nil + } + } + switch any(empty).(type) { case string: parsedValue = value @@ -465,6 +493,48 @@ func parseCLIArg[ parsedValue = t } + // Pointer-to-primitive flags reach here only when `value != "null"`; we parse the + // pointee type and return its address so JSON marshaling emits the underlying value. + case *string: + v := value + parsedValue = &v + case *int64: + var v int64 + v, err = strconv.ParseInt(value, 0, 64) + if err == nil { + parsedValue = &v + } + case *float64: + var v float64 + v, err = strconv.ParseFloat(value, 64) + if err == nil { + parsedValue = &v + } + case *bool: + var v bool + v, err = strconv.ParseBool(value) + if err == nil { + parsedValue = &v + } + case *DateTimeValue: + var dt DateTimeValue + err = (&dt).Parse(value) + if err == nil { + parsedValue = &dt + } + case *DateValue: + var d DateValue + err = (&d).Parse(value) + if err == nil { + parsedValue = &d + } + case *TimeValue: + var t TimeValue + err = (&t).Parse(value) + if err == nil { + parsedValue = &t + } + default: if strings.HasPrefix(value, "@") { // File literals like @file.txt should work here @@ -501,6 +571,13 @@ func parseCLIArg[ } +// Ptr returns a pointer to its argument. It is used to initialize `Default` on pointer-typed +// Flag values, since Go does not allow taking the address of a composite literal's element +// or of an untyped constant. +func Ptr[T any](v T) *T { + return &v +} + // Assuming this string failed to parse as valid YAML, this function will // return true for strings that can reasonably be interpreted as a string literal, // like identifiers (`foo_bar`), UUIDs (`945b2f0c-8e89-487a-b02c-f851c69ea459`), @@ -594,6 +671,15 @@ func (c *cliValue[T]) String() string { // For basic types, use standard string representation return fmt.Sprintf("%v", v) + case *string, *int64, *float64, *bool, *DateTimeValue, *DateValue, *TimeValue: + // Pointer-to-primitive: nil renders as "null" (the CLI literal that produces it); + // non-nil derefs to the pointee's standard representation. + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "null" + } + return fmt.Sprintf("%v", rv.Elem().Interface()) + default: // For complex types, convert to YAML yamlBytes, err := yaml.MarshalWithOptions(c.value, yaml.Flow(true)) @@ -705,6 +791,15 @@ type SettableInnerField interface { SetInnerField(string, any) } +// InnerFieldSeeder lets an InnerFlag prepare its outer flag's underlying value +// before dispatching SetInnerField. This is only meaningful for Flag[any] — +// the codegen output for nullable complex schemas — whose untyped-nil zero +// value would otherwise have no reflect.Kind for the inner-field switch to +// dispatch on. +type InnerFieldSeeder interface { + SeedInnerCollection(isArrayOfObjects bool) +} + func (f *Flag[T]) SetInnerField(field string, val any) { if f.value == nil { f.value = &cliValue[T]{} @@ -718,6 +813,33 @@ func (f *Flag[T]) SetInnerField(field string, val any) { } } +// SeedInnerCollection initializes a Flag[any]'s underlying value as an empty +// map[string]any or []map[string]any so subsequent SetInnerField calls have a +// dispatchable reflect.Kind. For typed Flag[T] this is a no-op: the type +// assertion fails and the existing reflect.Kind on the typed-nil zero value +// already routes correctly. +func (f *Flag[T]) SeedInnerCollection(isArrayOfObjects bool) { + if f.value == nil { + f.value = &cliValue[T]{} + } + cv, ok := f.value.(*cliValue[T]) + if !ok { + return + } + if reflect.ValueOf(cv.value).Kind() != reflect.Invalid { + return + } + if isArrayOfObjects { + if seed, ok := any([]map[string]any{}).(T); ok { + cv.value = seed + } + return + } + if seed, ok := any(map[string]any{}).(T); ok { + cv.value = seed + } +} + func (c *cliValue[T]) SetInnerField(field string, val any) { flagVal := c.value flagValReflect := reflect.ValueOf(flagVal) diff --git a/internal/requestflag/requestflag_test.go b/internal/requestflag/requestflag_test.go index 0e86e07..06ffb72 100644 --- a/internal/requestflag/requestflag_test.go +++ b/internal/requestflag/requestflag_test.go @@ -1,6 +1,7 @@ package requestflag import ( + "encoding/json" "fmt" "testing" "time" @@ -616,6 +617,178 @@ func TestYamlHandling(t *testing.T) { }) } +// TestNullLiteralHandling pins how each Flag[T] type handles the literal value "null" +// when passed via the CLI. Pointer-typed flags serialize nil as JSON null, which is how +// nullable body fields (`anyOf: [T, null]` / `{nullable: true}`) let users clear a field +// via `--foo null`. Non-pointer primitive flags treat "null" as a raw value — these are +// non-nullable schemas where explicit null has no API semantics anyway. +func TestNullLiteralHandling(t *testing.T) { + t.Parallel() + + assertJSONBody := func(t *testing.T, value any, expected string) { + t.Helper() + body, err := json.Marshal(map[string]any{"foo": value}) + assert.NoError(t, err) + assert.JSONEq(t, expected, string(body)) + } + + t.Run("Flag[any] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[any]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[string] null is the raw string \"null\"", func(t *testing.T) { + t.Parallel() + cv := &cliValue[string]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":"null"}`) + }) + + t.Run("Flag[int64] null errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[int64]{} + assert.Error(t, cv.Set("null")) + }) + + t.Run("Flag[*string] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*string]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*string] value sends the string", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*string]{} + assert.NoError(t, cv.Set("1.1")) + assertJSONBody(t, cv.Get(), `{"foo":"1.1"}`) + }) + + t.Run("Flag[*int64] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*int64]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*int64] value sends the integer", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*int64]{} + assert.NoError(t, cv.Set("42")) + assertJSONBody(t, cv.Get(), `{"foo":42}`) + }) + + t.Run("Flag[*int64] invalid value errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*int64]{} + assert.Error(t, cv.Set("not-an-int")) + }) + + t.Run("Flag[*bool] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*bool]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*bool] value sends the boolean", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*bool]{} + assert.NoError(t, cv.Set("true")) + assertJSONBody(t, cv.Get(), `{"foo":true}`) + }) + + t.Run("Flag[*float64] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*float64]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*float64] value sends the float", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*float64]{} + assert.NoError(t, cv.Set("1.5")) + assertJSONBody(t, cv.Get(), `{"foo":1.5}`) + }) + + t.Run("Flag[*float64] invalid value errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*float64]{} + assert.Error(t, cv.Set("not-a-float")) + }) + + t.Run("Flag[*DateValue] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateValue]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*DateValue] value sends the date", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateValue]{} + assert.NoError(t, cv.Set("2023-05-15")) + assertJSONBody(t, cv.Get(), `{"foo":"2023-05-15"}`) + }) + + t.Run("Flag[*DateValue] invalid value errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateValue]{} + assert.Error(t, cv.Set("not-a-date")) + }) + + t.Run("Flag[*DateTimeValue] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateTimeValue]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*DateTimeValue] value sends the datetime", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateTimeValue]{} + assert.NoError(t, cv.Set("2023-05-15T14:30:45Z")) + assertJSONBody(t, cv.Get(), `{"foo":"2023-05-15T14:30:45Z"}`) + }) + + t.Run("Flag[*DateTimeValue] invalid value errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*DateTimeValue]{} + assert.Error(t, cv.Set("not-a-datetime")) + }) + + t.Run("Flag[*TimeValue] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*TimeValue]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) + + t.Run("Flag[*TimeValue] value sends the time", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*TimeValue]{} + assert.NoError(t, cv.Set("14:30:45")) + assertJSONBody(t, cv.Get(), `{"foo":"14:30:45"}`) + }) + + t.Run("Flag[*TimeValue] invalid value errors", func(t *testing.T) { + t.Parallel() + cv := &cliValue[*TimeValue]{} + assert.Error(t, cv.Set("not-a-time")) + }) + + // Nullable maps don't need pointer wrapping — a nil map already marshals as JSON null. + t.Run("Flag[map[string]any] null sends JSON null", func(t *testing.T) { + t.Parallel() + cv := &cliValue[map[string]any]{} + assert.NoError(t, cv.Set("null")) + assertJSONBody(t, cv.Get(), `{"foo":null}`) + }) +} + func TestFlagTypeNames(t *testing.T) { t.Parallel() @@ -646,3 +819,64 @@ func TestFlagTypeNames(t *testing.T) { }) } } + +// TestInnerFlagDispatchOnUntypedFlag pins inner-flag behavior for `Flag[any]`, +// which is the codegen output for nullable complex schemas (`anyOf: [T, null]` +// or `{nullable: true}`). The untyped-nil zero value carries no reflect.Kind, +// so SetInnerField has nowhere to dispatch the assignment — without explicit +// help the inner-field value silently drops. +func TestInnerFlagDispatchOnUntypedFlag(t *testing.T) { + t.Parallel() + + t.Run("nullable array of objects appends element from inner flag", func(t *testing.T) { + t.Parallel() + outer := &Flag[any]{Name: "mcp-server"} + assert.NoError(t, outer.PreParse()) + + nameFlag := &InnerFlag[string]{ + Name: "mcp-server.name", InnerField: "name", + OuterFlag: outer, OuterIsArrayOfObjects: true, + } + assert.NoError(t, nameFlag.Set("mcp-server.name", "first")) + + body, err := json.Marshal(map[string]any{"foo": outer.Get()}) + assert.NoError(t, err) + assert.JSONEq(t, `{"foo":[{"name":"first"}]}`, string(body)) + }) + + t.Run("nullable object sets field from inner flag", func(t *testing.T) { + t.Parallel() + outer := &Flag[any]{Name: "metadata"} + assert.NoError(t, outer.PreParse()) + + keyFlag := &InnerFlag[string]{ + Name: "metadata.key", InnerField: "key", OuterFlag: outer, + } + assert.NoError(t, keyFlag.Set("metadata.key", "value")) + + body, err := json.Marshal(map[string]any{"foo": outer.Get()}) + assert.NoError(t, err) + assert.JSONEq(t, `{"foo":{"key":"value"}}`, string(body)) + }) + + t.Run("multiple inner flags merge into the trailing element", func(t *testing.T) { + t.Parallel() + outer := &Flag[any]{Name: "mcp-server"} + assert.NoError(t, outer.PreParse()) + + nameFlag := &InnerFlag[string]{ + Name: "mcp-server.name", InnerField: "name", + OuterFlag: outer, OuterIsArrayOfObjects: true, + } + urlFlag := &InnerFlag[string]{ + Name: "mcp-server.url", InnerField: "url", + OuterFlag: outer, OuterIsArrayOfObjects: true, + } + assert.NoError(t, nameFlag.Set("mcp-server.name", "first")) + assert.NoError(t, urlFlag.Set("mcp-server.url", "https://example.com")) + + body, err := json.Marshal(map[string]any{"foo": outer.Get()}) + assert.NoError(t, err) + assert.JSONEq(t, `{"foo":[{"name":"first","url":"https://example.com"}]}`, string(body)) + }) +} diff --git a/pkg/cmd/apikey.go b/pkg/cmd/apikey.go index 0757427..a1e4225 100644 --- a/pkg/cmd/apikey.go +++ b/pkg/cmd/apikey.go @@ -19,7 +19,7 @@ var apiKeysCreate = requestflag.WithInnerFlags(cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "name", Usage: "Name of api key.", BodyPath: "name", @@ -34,177 +34,177 @@ var apiKeysCreate = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "permissions": { - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-create", Usage: "Create API keys.", InnerField: "api_key_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-delete", Usage: "Delete API keys.", InnerField: "api_key_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-read", Usage: "Read API keys.", InnerField: "api_key_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-create", Usage: "Create domains.", InnerField: "domain_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-delete", Usage: "Delete domains.", InnerField: "domain_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-read", Usage: "Read domain details.", InnerField: "domain_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-update", Usage: "Update domains.", InnerField: "domain_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-create", Usage: "Create drafts.", InnerField: "draft_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-delete", Usage: "Delete drafts.", InnerField: "draft_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-read", Usage: "Read drafts.", InnerField: "draft_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-send", Usage: "Send drafts.", InnerField: "draft_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-update", Usage: "Update drafts.", InnerField: "draft_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-create", Usage: "Create new inboxes.", InnerField: "inbox_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-delete", Usage: "Delete inboxes.", InnerField: "inbox_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-read", Usage: "Read inbox details.", InnerField: "inbox_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-update", Usage: "Update inbox settings.", InnerField: "inbox_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-blocked-read", Usage: "Access messages labeled blocked.", InnerField: "label_blocked_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-spam-read", Usage: "Access messages labeled spam.", InnerField: "label_spam_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-trash-read", Usage: "Access messages labeled trash.", InnerField: "label_trash_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-create", Usage: "Create list entries.", InnerField: "list_entry_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-delete", Usage: "Delete list entries.", InnerField: "list_entry_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-read", Usage: "Read list entries.", InnerField: "list_entry_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-read", Usage: "Read messages.", InnerField: "message_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-send", Usage: "Send messages.", InnerField: "message_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-update", Usage: "Update message labels.", InnerField: "message_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.metrics-read", Usage: "Read metrics.", InnerField: "metrics_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-create", Usage: "Create pods.", InnerField: "pod_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-delete", Usage: "Delete pods.", InnerField: "pod_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-read", Usage: "Read pods.", InnerField: "pod_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-delete", Usage: "Delete threads.", InnerField: "thread_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-read", Usage: "Read threads.", InnerField: "thread_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-create", Usage: "Create webhooks.", InnerField: "webhook_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-delete", Usage: "Delete webhooks.", InnerField: "webhook_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-read", Usage: "Read webhook configurations.", InnerField: "webhook_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-update", Usage: "Update webhooks.", InnerField: "webhook_update", @@ -217,17 +217,17 @@ var apiKeysList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/domain.go b/pkg/cmd/domain.go index facdb1a..85af514 100644 --- a/pkg/cmd/domain.go +++ b/pkg/cmd/domain.go @@ -46,7 +46,7 @@ var domainsUpdate = cli.Command{ Usage: "The ID of the domain.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "feedback-enabled", Usage: "Bounce and complaint notifications are sent to your inboxes.", BodyPath: "feedback_enabled", @@ -61,17 +61,17 @@ var domainsList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/draft.go b/pkg/cmd/draft.go index 0b5a8b9..3d79ad0 100644 --- a/pkg/cmd/draft.go +++ b/pkg/cmd/draft.go @@ -24,7 +24,7 @@ var draftsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -39,12 +39,12 @@ var draftsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/inbox.go b/pkg/cmd/inbox.go index f6b2dd1..8c94641 100644 --- a/pkg/cmd/inbox.go +++ b/pkg/cmd/inbox.go @@ -19,22 +19,22 @@ var inboxesCreate = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "client-id", Usage: "Client ID of inbox.", BodyPath: "client_id", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "display-name", Usage: "Display name: `Display Name `.", BodyPath: "display_name", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "domain", Usage: "Domain of address. Must be verified domain. Defaults to `agentmail.to`.", BodyPath: "domain", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "username", Usage: "Username of address. Randomly generated if not specified.", BodyPath: "username", @@ -70,17 +70,17 @@ var inboxesList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", @@ -130,7 +130,7 @@ var inboxesListMetrics = cli.Command{ Usage: "The ID of the inbox.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "descending", Usage: "Sort in descending order.", QueryPath: "descending", @@ -145,12 +145,12 @@ var inboxesListMetrics = cli.Command{ Usage: "List of metric event types to query.", QueryPath: "event_types", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit on number of buckets to return.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "period", Usage: "Period in number of seconds for the query.", QueryPath: "period", diff --git a/pkg/cmd/inboxapikey.go b/pkg/cmd/inboxapikey.go index a59e810..49fe56a 100644 --- a/pkg/cmd/inboxapikey.go +++ b/pkg/cmd/inboxapikey.go @@ -24,7 +24,7 @@ var inboxesAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ Usage: "The ID of the inbox.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "name", Usage: "Name of api key.", BodyPath: "name", @@ -39,177 +39,177 @@ var inboxesAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "permissions": { - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-create", Usage: "Create API keys.", InnerField: "api_key_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-delete", Usage: "Delete API keys.", InnerField: "api_key_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-read", Usage: "Read API keys.", InnerField: "api_key_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-create", Usage: "Create domains.", InnerField: "domain_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-delete", Usage: "Delete domains.", InnerField: "domain_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-read", Usage: "Read domain details.", InnerField: "domain_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-update", Usage: "Update domains.", InnerField: "domain_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-create", Usage: "Create drafts.", InnerField: "draft_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-delete", Usage: "Delete drafts.", InnerField: "draft_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-read", Usage: "Read drafts.", InnerField: "draft_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-send", Usage: "Send drafts.", InnerField: "draft_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-update", Usage: "Update drafts.", InnerField: "draft_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-create", Usage: "Create new inboxes.", InnerField: "inbox_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-delete", Usage: "Delete inboxes.", InnerField: "inbox_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-read", Usage: "Read inbox details.", InnerField: "inbox_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-update", Usage: "Update inbox settings.", InnerField: "inbox_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-blocked-read", Usage: "Access messages labeled blocked.", InnerField: "label_blocked_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-spam-read", Usage: "Access messages labeled spam.", InnerField: "label_spam_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-trash-read", Usage: "Access messages labeled trash.", InnerField: "label_trash_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-create", Usage: "Create list entries.", InnerField: "list_entry_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-delete", Usage: "Delete list entries.", InnerField: "list_entry_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-read", Usage: "Read list entries.", InnerField: "list_entry_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-read", Usage: "Read messages.", InnerField: "message_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-send", Usage: "Send messages.", InnerField: "message_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-update", Usage: "Update message labels.", InnerField: "message_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.metrics-read", Usage: "Read metrics.", InnerField: "metrics_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-create", Usage: "Create pods.", InnerField: "pod_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-delete", Usage: "Delete pods.", InnerField: "pod_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-read", Usage: "Read pods.", InnerField: "pod_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-delete", Usage: "Delete threads.", InnerField: "thread_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-read", Usage: "Read threads.", InnerField: "thread_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-create", Usage: "Create webhooks.", InnerField: "webhook_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-delete", Usage: "Delete webhooks.", InnerField: "webhook_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-read", Usage: "Read webhook configurations.", InnerField: "webhook_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-update", Usage: "Update webhooks.", InnerField: "webhook_update", @@ -227,12 +227,12 @@ var inboxesAPIKeysList = cli.Command{ Usage: "The ID of the inbox.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/inboxdraft.go b/pkg/cmd/inboxdraft.go index 0f11108..7e3186c 100644 --- a/pkg/cmd/inboxdraft.go +++ b/pkg/cmd/inboxdraft.go @@ -39,17 +39,17 @@ var inboxesDraftsCreate = requestflag.WithInnerFlags(cli.Command{ Usage: "Addresses of CC recipients. In format `username@domain.com` or `Display Name `.", BodyPath: "cc", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "client-id", Usage: "Client ID of draft.", BodyPath: "client_id", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of draft.", BodyPath: "html", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "in-reply-to", Usage: "ID of message being replied to.", BodyPath: "in_reply_to", @@ -69,12 +69,12 @@ var inboxesDraftsCreate = requestflag.WithInnerFlags(cli.Command{ Usage: "Time at which to schedule send draft.", BodyPath: "send_at", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "subject", Usage: "Subject of draft.", BodyPath: "subject", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of draft.", BodyPath: "text", @@ -89,35 +89,41 @@ var inboxesDraftsCreate = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "attachment": { - &requestflag.InnerFlag[any]{ - Name: "attachment.content", - Usage: "Base64 encoded content of attachment.", - InnerField: "content", - }, - &requestflag.InnerFlag[string]{ - Name: "attachment.content-disposition", - Usage: "Content disposition of attachment.", - InnerField: "content_disposition", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-id", - Usage: "Content ID of attachment.", - InnerField: "content_id", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-type", - Usage: "Content type of attachment.", - InnerField: "content_type", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.filename", - Usage: "Filename of attachment.", - InnerField: "filename", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.url", - Usage: "URL to the attachment.", - InnerField: "url", + &requestflag.InnerFlag[*string]{ + Name: "attachment.content", + Usage: "Base64 encoded content of attachment.", + InnerField: "content", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-disposition", + Usage: "Content disposition of attachment.", + InnerField: "content_disposition", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-id", + Usage: "Content ID of attachment.", + InnerField: "content_id", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-type", + Usage: "Content type of attachment.", + InnerField: "content_type", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.filename", + Usage: "Filename of attachment.", + InnerField: "filename", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.url", + Usage: "URL to the attachment.", + InnerField: "url", + OuterIsArrayOfObjects: true, }, }, }) @@ -147,7 +153,7 @@ var inboxesDraftsUpdate = cli.Command{ Usage: "Addresses of CC recipients. In format `username@domain.com` or `Display Name `.", BodyPath: "cc", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of draft.", BodyPath: "html", @@ -162,12 +168,12 @@ var inboxesDraftsUpdate = cli.Command{ Usage: "Time at which to schedule send draft.", BodyPath: "send_at", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "subject", Usage: "Subject of draft.", BodyPath: "subject", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of draft.", BodyPath: "text", @@ -197,7 +203,7 @@ var inboxesDraftsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -212,12 +218,12 @@ var inboxesDraftsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/inboxlist.go b/pkg/cmd/inboxlist.go index c0517a1..8a7de73 100644 --- a/pkg/cmd/inboxlist.go +++ b/pkg/cmd/inboxlist.go @@ -40,7 +40,7 @@ var inboxesListsCreate = cli.Command{ Required: true, BodyPath: "entry", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "reason", Usage: "Reason for adding the entry.", BodyPath: "reason", @@ -70,12 +70,12 @@ var inboxesListsList = cli.Command{ Usage: "Type of list entry.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index e1b480c..ec9078f 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -59,7 +59,7 @@ var inboxesMessagesList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -69,17 +69,17 @@ var inboxesMessagesList = cli.Command{ Usage: "Timestamp before which to filter by.", QueryPath: "before", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-blocked", Usage: "Include blocked in results.", QueryPath: "include_blocked", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-spam", Usage: "Include spam in results.", QueryPath: "include_spam", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-trash", Usage: "Include trash in results.", QueryPath: "include_trash", @@ -89,12 +89,12 @@ var inboxesMessagesList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", @@ -137,7 +137,7 @@ var inboxesMessagesForward = requestflag.WithInnerFlags(cli.Command{ Usage: "Headers to include in message.", BodyPath: "headers", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of message.", BodyPath: "html", @@ -151,12 +151,12 @@ var inboxesMessagesForward = requestflag.WithInnerFlags(cli.Command{ Name: "reply-to", BodyPath: "reply_to", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "subject", Usage: "Subject of message.", BodyPath: "subject", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of message.", BodyPath: "text", @@ -170,35 +170,41 @@ var inboxesMessagesForward = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "attachment": { - &requestflag.InnerFlag[any]{ - Name: "attachment.content", - Usage: "Base64 encoded content of attachment.", - InnerField: "content", - }, - &requestflag.InnerFlag[string]{ - Name: "attachment.content-disposition", - Usage: "Content disposition of attachment.", - InnerField: "content_disposition", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-id", - Usage: "Content ID of attachment.", - InnerField: "content_id", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-type", - Usage: "Content type of attachment.", - InnerField: "content_type", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.filename", - Usage: "Filename of attachment.", - InnerField: "filename", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.url", - Usage: "URL to the attachment.", - InnerField: "url", + &requestflag.InnerFlag[*string]{ + Name: "attachment.content", + Usage: "Base64 encoded content of attachment.", + InnerField: "content", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-disposition", + Usage: "Content disposition of attachment.", + InnerField: "content_disposition", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-id", + Usage: "Content ID of attachment.", + InnerField: "content_id", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-type", + Usage: "Content type of attachment.", + InnerField: "content_type", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.filename", + Usage: "Filename of attachment.", + InnerField: "filename", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.url", + Usage: "URL to the attachment.", + InnerField: "url", + OuterIsArrayOfObjects: true, }, }, }) @@ -301,7 +307,7 @@ var inboxesMessagesReply = requestflag.WithInnerFlags(cli.Command{ Usage: "Headers to include in message.", BodyPath: "headers", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of message.", BodyPath: "html", @@ -311,7 +317,7 @@ var inboxesMessagesReply = requestflag.WithInnerFlags(cli.Command{ Usage: "Labels of message.", BodyPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "reply-all", Usage: "Reply to all recipients of the original message.", BodyPath: "reply_all", @@ -320,7 +326,7 @@ var inboxesMessagesReply = requestflag.WithInnerFlags(cli.Command{ Name: "reply-to", BodyPath: "reply_to", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of message.", BodyPath: "text", @@ -334,35 +340,41 @@ var inboxesMessagesReply = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "attachment": { - &requestflag.InnerFlag[any]{ - Name: "attachment.content", - Usage: "Base64 encoded content of attachment.", - InnerField: "content", - }, - &requestflag.InnerFlag[string]{ - Name: "attachment.content-disposition", - Usage: "Content disposition of attachment.", - InnerField: "content_disposition", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-id", - Usage: "Content ID of attachment.", - InnerField: "content_id", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-type", - Usage: "Content type of attachment.", - InnerField: "content_type", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.filename", - Usage: "Filename of attachment.", - InnerField: "filename", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.url", - Usage: "URL to the attachment.", - InnerField: "url", + &requestflag.InnerFlag[*string]{ + Name: "attachment.content", + Usage: "Base64 encoded content of attachment.", + InnerField: "content", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-disposition", + Usage: "Content disposition of attachment.", + InnerField: "content_disposition", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-id", + Usage: "Content ID of attachment.", + InnerField: "content_id", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-type", + Usage: "Content type of attachment.", + InnerField: "content_type", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.filename", + Usage: "Filename of attachment.", + InnerField: "filename", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.url", + Usage: "URL to the attachment.", + InnerField: "url", + OuterIsArrayOfObjects: true, }, }, }) @@ -392,7 +404,7 @@ var inboxesMessagesReplyAll = requestflag.WithInnerFlags(cli.Command{ Usage: "Headers to include in message.", BodyPath: "headers", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of message.", BodyPath: "html", @@ -406,7 +418,7 @@ var inboxesMessagesReplyAll = requestflag.WithInnerFlags(cli.Command{ Name: "reply-to", BodyPath: "reply_to", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of message.", BodyPath: "text", @@ -416,35 +428,41 @@ var inboxesMessagesReplyAll = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "attachment": { - &requestflag.InnerFlag[any]{ - Name: "attachment.content", - Usage: "Base64 encoded content of attachment.", - InnerField: "content", - }, - &requestflag.InnerFlag[string]{ - Name: "attachment.content-disposition", - Usage: "Content disposition of attachment.", - InnerField: "content_disposition", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-id", - Usage: "Content ID of attachment.", - InnerField: "content_id", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-type", - Usage: "Content type of attachment.", - InnerField: "content_type", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.filename", - Usage: "Filename of attachment.", - InnerField: "filename", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.url", - Usage: "URL to the attachment.", - InnerField: "url", + &requestflag.InnerFlag[*string]{ + Name: "attachment.content", + Usage: "Base64 encoded content of attachment.", + InnerField: "content", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-disposition", + Usage: "Content disposition of attachment.", + InnerField: "content_disposition", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-id", + Usage: "Content ID of attachment.", + InnerField: "content_id", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-type", + Usage: "Content type of attachment.", + InnerField: "content_type", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.filename", + Usage: "Filename of attachment.", + InnerField: "filename", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.url", + Usage: "URL to the attachment.", + InnerField: "url", + OuterIsArrayOfObjects: true, }, }, }) @@ -477,7 +495,7 @@ var inboxesMessagesSend = requestflag.WithInnerFlags(cli.Command{ Usage: "Headers to include in message.", BodyPath: "headers", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "html", Usage: "HTML body of message.", BodyPath: "html", @@ -491,12 +509,12 @@ var inboxesMessagesSend = requestflag.WithInnerFlags(cli.Command{ Name: "reply-to", BodyPath: "reply_to", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "subject", Usage: "Subject of message.", BodyPath: "subject", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "text", Usage: "Plain text body of message.", BodyPath: "text", @@ -510,35 +528,41 @@ var inboxesMessagesSend = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "attachment": { - &requestflag.InnerFlag[any]{ - Name: "attachment.content", - Usage: "Base64 encoded content of attachment.", - InnerField: "content", - }, - &requestflag.InnerFlag[string]{ - Name: "attachment.content-disposition", - Usage: "Content disposition of attachment.", - InnerField: "content_disposition", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-id", - Usage: "Content ID of attachment.", - InnerField: "content_id", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.content-type", - Usage: "Content type of attachment.", - InnerField: "content_type", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.filename", - Usage: "Filename of attachment.", - InnerField: "filename", - }, - &requestflag.InnerFlag[any]{ - Name: "attachment.url", - Usage: "URL to the attachment.", - InnerField: "url", + &requestflag.InnerFlag[*string]{ + Name: "attachment.content", + Usage: "Base64 encoded content of attachment.", + InnerField: "content", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-disposition", + Usage: "Content disposition of attachment.", + InnerField: "content_disposition", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-id", + Usage: "Content ID of attachment.", + InnerField: "content_id", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.content-type", + Usage: "Content type of attachment.", + InnerField: "content_type", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.filename", + Usage: "Filename of attachment.", + InnerField: "filename", + OuterIsArrayOfObjects: true, + }, + &requestflag.InnerFlag[*string]{ + Name: "attachment.url", + Usage: "URL to the attachment.", + InnerField: "url", + OuterIsArrayOfObjects: true, }, }, }) diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index 59738c6..2de33ec 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -29,7 +29,7 @@ var inboxesThreadsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -39,17 +39,17 @@ var inboxesThreadsList = cli.Command{ Usage: "Timestamp before which to filter by.", QueryPath: "before", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-blocked", Usage: "Include blocked in results.", QueryPath: "include_blocked", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-spam", Usage: "Include spam in results.", QueryPath: "include_spam", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-trash", Usage: "Include trash in results.", QueryPath: "include_trash", @@ -59,12 +59,12 @@ var inboxesThreadsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", @@ -89,7 +89,7 @@ var inboxesThreadsDelete = cli.Command{ Usage: "ID of thread.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "permanent", Usage: "If true, permanently delete the thread instead of moving to trash.", QueryPath: "permanent", diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index d269bea..99c647a 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -35,7 +35,7 @@ var listsCreate = cli.Command{ Required: true, BodyPath: "entry", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "reason", Usage: "Reason for adding the entry.", BodyPath: "reason", @@ -60,12 +60,12 @@ var listsList = cli.Command{ Usage: "Type of list entry.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/metric.go b/pkg/cmd/metric.go index 380516a..550eaa3 100644 --- a/pkg/cmd/metric.go +++ b/pkg/cmd/metric.go @@ -19,7 +19,7 @@ var metricsList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "descending", Usage: "Sort in descending order.", QueryPath: "descending", @@ -34,12 +34,12 @@ var metricsList = cli.Command{ Usage: "List of metric event types to query.", QueryPath: "event_types", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit on number of buckets to return.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "period", Usage: "Period in number of seconds for the query.", QueryPath: "period", diff --git a/pkg/cmd/pod.go b/pkg/cmd/pod.go index c6ac651..9a2a717 100644 --- a/pkg/cmd/pod.go +++ b/pkg/cmd/pod.go @@ -19,12 +19,12 @@ var podsCreate = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "client-id", Usage: "Client ID of pod.", BodyPath: "client_id", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "name", Usage: "Name of pod.", BodyPath: "name", @@ -39,17 +39,17 @@ var podsList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/podapikey.go b/pkg/cmd/podapikey.go index 46d0731..84a9ad8 100644 --- a/pkg/cmd/podapikey.go +++ b/pkg/cmd/podapikey.go @@ -24,7 +24,7 @@ var podsAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "name", Usage: "Name of api key.", BodyPath: "name", @@ -39,177 +39,177 @@ var podsAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ HideHelpCommand: true, }, map[string][]requestflag.HasOuterFlag{ "permissions": { - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-create", Usage: "Create API keys.", InnerField: "api_key_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-delete", Usage: "Delete API keys.", InnerField: "api_key_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.api-key-read", Usage: "Read API keys.", InnerField: "api_key_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-create", Usage: "Create domains.", InnerField: "domain_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-delete", Usage: "Delete domains.", InnerField: "domain_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-read", Usage: "Read domain details.", InnerField: "domain_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.domain-update", Usage: "Update domains.", InnerField: "domain_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-create", Usage: "Create drafts.", InnerField: "draft_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-delete", Usage: "Delete drafts.", InnerField: "draft_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-read", Usage: "Read drafts.", InnerField: "draft_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-send", Usage: "Send drafts.", InnerField: "draft_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.draft-update", Usage: "Update drafts.", InnerField: "draft_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-create", Usage: "Create new inboxes.", InnerField: "inbox_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-delete", Usage: "Delete inboxes.", InnerField: "inbox_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-read", Usage: "Read inbox details.", InnerField: "inbox_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.inbox-update", Usage: "Update inbox settings.", InnerField: "inbox_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-blocked-read", Usage: "Access messages labeled blocked.", InnerField: "label_blocked_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-spam-read", Usage: "Access messages labeled spam.", InnerField: "label_spam_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.label-trash-read", Usage: "Access messages labeled trash.", InnerField: "label_trash_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-create", Usage: "Create list entries.", InnerField: "list_entry_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-delete", Usage: "Delete list entries.", InnerField: "list_entry_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.list-entry-read", Usage: "Read list entries.", InnerField: "list_entry_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-read", Usage: "Read messages.", InnerField: "message_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-send", Usage: "Send messages.", InnerField: "message_send", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.message-update", Usage: "Update message labels.", InnerField: "message_update", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.metrics-read", Usage: "Read metrics.", InnerField: "metrics_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-create", Usage: "Create pods.", InnerField: "pod_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-delete", Usage: "Delete pods.", InnerField: "pod_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.pod-read", Usage: "Read pods.", InnerField: "pod_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-delete", Usage: "Delete threads.", InnerField: "thread_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.thread-read", Usage: "Read threads.", InnerField: "thread_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-create", Usage: "Create webhooks.", InnerField: "webhook_create", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-delete", Usage: "Delete webhooks.", InnerField: "webhook_delete", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-read", Usage: "Read webhook configurations.", InnerField: "webhook_read", }, - &requestflag.InnerFlag[any]{ + &requestflag.InnerFlag[*bool]{ Name: "permissions.webhook-update", Usage: "Update webhooks.", InnerField: "webhook_update", @@ -227,12 +227,12 @@ var podsAPIKeysList = cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/poddomain.go b/pkg/cmd/poddomain.go index fd25dad..d25e0f4 100644 --- a/pkg/cmd/poddomain.go +++ b/pkg/cmd/poddomain.go @@ -56,7 +56,7 @@ var podsDomainsUpdate = cli.Command{ Usage: "The ID of the domain.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "feedback-enabled", Usage: "Bounce and complaint notifications are sent to your inboxes.", BodyPath: "feedback_enabled", @@ -76,17 +76,17 @@ var podsDomainsList = cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/poddraft.go b/pkg/cmd/poddraft.go index c989561..3b5378c 100644 --- a/pkg/cmd/poddraft.go +++ b/pkg/cmd/poddraft.go @@ -29,7 +29,7 @@ var podsDraftsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -44,12 +44,12 @@ var podsDraftsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/podinbox.go b/pkg/cmd/podinbox.go index c004633..c266eea 100644 --- a/pkg/cmd/podinbox.go +++ b/pkg/cmd/podinbox.go @@ -24,22 +24,22 @@ var podsInboxesCreate = cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "client-id", Usage: "Client ID of inbox.", BodyPath: "client_id", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "display-name", Usage: "Display name: `Display Name `.", BodyPath: "display_name", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "domain", Usage: "Domain of address. Must be verified domain. Defaults to `agentmail.to`.", BodyPath: "domain", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "username", Usage: "Username of address. Randomly generated if not specified.", BodyPath: "username", @@ -85,17 +85,17 @@ var podsInboxesList = cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/podlist.go b/pkg/cmd/podlist.go index 7a97f1e..da488ee 100644 --- a/pkg/cmd/podlist.go +++ b/pkg/cmd/podlist.go @@ -40,7 +40,7 @@ var podsListsCreate = cli.Command{ Required: true, BodyPath: "entry", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "reason", Usage: "Reason for adding the entry.", BodyPath: "reason", @@ -70,12 +70,12 @@ var podsListsList = cli.Command{ Usage: "Type of list entry.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", diff --git a/pkg/cmd/podmetric.go b/pkg/cmd/podmetric.go index 56882e9..d1afc62 100644 --- a/pkg/cmd/podmetric.go +++ b/pkg/cmd/podmetric.go @@ -24,7 +24,7 @@ var podsMetricsQuery = cli.Command{ Usage: "ID of pod.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "descending", Usage: "Sort in descending order.", QueryPath: "descending", @@ -39,12 +39,12 @@ var podsMetricsQuery = cli.Command{ Usage: "List of metric event types to query.", QueryPath: "event_types", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit on number of buckets to return.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "period", Usage: "Period in number of seconds for the query.", QueryPath: "period", diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index 9858421..23834a6 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -29,7 +29,7 @@ var podsThreadsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -39,17 +39,17 @@ var podsThreadsList = cli.Command{ Usage: "Timestamp before which to filter by.", QueryPath: "before", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-blocked", Usage: "Include blocked in results.", QueryPath: "include_blocked", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-spam", Usage: "Include spam in results.", QueryPath: "include_spam", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-trash", Usage: "Include trash in results.", QueryPath: "include_trash", @@ -59,12 +59,12 @@ var podsThreadsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", @@ -89,7 +89,7 @@ var podsThreadsDelete = cli.Command{ Usage: "ID of thread.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "permanent", Usage: "If true, permanently delete the thread instead of moving to trash.", QueryPath: "permanent", diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index 96dd42b..dbc0a6a 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -24,7 +24,7 @@ var threadsList = cli.Command{ Usage: "Timestamp after which to filter by.", QueryPath: "after", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", @@ -34,17 +34,17 @@ var threadsList = cli.Command{ Usage: "Timestamp before which to filter by.", QueryPath: "before", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-blocked", Usage: "Include blocked in results.", QueryPath: "include_blocked", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-spam", Usage: "Include spam in results.", QueryPath: "include_spam", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "include-trash", Usage: "Include trash in results.", QueryPath: "include_trash", @@ -54,12 +54,12 @@ var threadsList = cli.Command{ Usage: "Labels to filter by.", QueryPath: "labels", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", @@ -79,7 +79,7 @@ var threadsDelete = cli.Command{ Usage: "ID of thread.", Required: true, }, - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "permanent", Usage: "If true, permanently delete the thread instead of moving to trash.", QueryPath: "permanent", diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index 99254d4..2121faa 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -31,7 +31,7 @@ var webhooksCreate = cli.Command{ Required: true, BodyPath: "url", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "client-id", Usage: "Client ID of webhook.", BodyPath: "client_id", @@ -91,17 +91,17 @@ var webhooksList = cli.Command{ Usage: "**CLI:**", Suggest: true, Flags: []cli.Flag{ - &requestflag.Flag[any]{ + &requestflag.Flag[*bool]{ Name: "ascending", Usage: "Sort in ascending temporal order.", QueryPath: "ascending", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*int64]{ Name: "limit", Usage: "Limit of number of items returned.", QueryPath: "limit", }, - &requestflag.Flag[any]{ + &requestflag.Flag[*string]{ Name: "page-token", Usage: "Page token for pagination.", QueryPath: "page_token", From 86c8aab82328e0362b0d699464f1a55a9421b4e7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:23:32 +0000 Subject: [PATCH 19/31] feat: support passing path and query params over stdin --- internal/requestflag/requestflag.go | 115 +++++++- internal/requestflag/requestflag_test.go | 345 +++++++++++++++++++++++ pkg/cmd/agent.go | 8 +- pkg/cmd/apikey.go | 15 +- pkg/cmd/domain.go | 47 +-- pkg/cmd/draft.go | 33 ++- pkg/cmd/flagoptions.go | 48 +++- pkg/cmd/inbox.go | 44 +-- pkg/cmd/inboxapikey.go | 44 +-- pkg/cmd/inboxdraft.go | 141 ++++----- pkg/cmd/inboxlist.go | 138 +++++---- pkg/cmd/inboxmessage.go | 185 ++++++------ pkg/cmd/inboxthread.go | 86 +++--- pkg/cmd/list.go | 102 ++++--- pkg/cmd/metric.go | 4 +- pkg/cmd/pod.go | 22 +- pkg/cmd/podapikey.go | 44 +-- pkg/cmd/poddomain.go | 132 +++++---- pkg/cmd/poddraft.go | 64 +++-- pkg/cmd/podinbox.go | 88 +++--- pkg/cmd/podlist.go | 138 +++++---- pkg/cmd/podmetric.go | 11 +- pkg/cmd/podthread.go | 86 +++--- pkg/cmd/thread.go | 44 +-- pkg/cmd/webhook.go | 33 ++- 25 files changed, 1321 insertions(+), 696 deletions(-) diff --git a/internal/requestflag/requestflag.go b/internal/requestflag/requestflag.go index 54c2509..77c4f1f 100644 --- a/internal/requestflag/requestflag.go +++ b/internal/requestflag/requestflag.go @@ -1,6 +1,7 @@ package requestflag import ( + "encoding/json" "fmt" "reflect" "strconv" @@ -12,6 +13,26 @@ import ( "github.com/urfave/cli/v3" ) +// formatForFlagSet converts a Go value parsed from YAML/JSON stdin data into a string +// that flag.Set (and thus parseCLIArg) can parse correctly for each flag type. +// Strings are returned as-is (parseCLIArg[string] assigns the raw value directly, so +// JSON-quoting must be avoided). Scalars use %v. Complex types (maps, slices) are +// JSON-encoded, which the yaml.Unmarshal default branch in parseCLIArg can parse. +func formatForFlagSet(val any) (string, error) { + switch v := val.(type) { + case string: + return v, nil + case bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64: + return fmt.Sprintf("%v", val), nil + default: + b, err := json.Marshal(val) + if err != nil { + return "", fmt.Errorf("cannot format value %T for flag.Set: %w", val, err) + } + return string(b), nil + } +} + // Flag [T] is a generic flag base which can be used to implement the most // common interfaces used by urfave/cli. Additionally, it allows specifying // where in an HTTP request the flag values should be placed (e.g. query, body, etc.). @@ -41,6 +62,7 @@ type Flag[ HeaderPath string // location in the request header to put this flag's value BodyPath string // location in the request body to put this flag's value BodyRoot bool // if true, then use this value as the entire request body + PathParam string // name of the URL path parameter this flag's value maps to // Const, when true, marks this flag as a constant. The flag's Default value is used as the fixed value // and always included in the request (IsSet returns true). The user can still see and override the flag, @@ -72,6 +94,7 @@ type InRequest interface { GetQueryPath() string GetHeaderPath() string GetBodyPath() string + GetPathParam() string IsBodyRoot() bool IsFileInput() bool GetDataAliases() []string @@ -89,6 +112,10 @@ func (f Flag[T]) GetBodyPath() string { return f.BodyPath } +func (f Flag[T]) GetPathParam() string { + return f.PathParam +} + func (f Flag[T]) IsBodyRoot() bool { return f.BodyRoot } @@ -108,7 +135,91 @@ type RequestContents struct { Body any } -// Extract query parameters, headers, and body values from command flags. +// ApplyStdinDataToFlags sets flag values from a parsed stdin data map for flags that have not already been +// set via the command line. This allows piped YAML/JSON data to satisfy path, query, and header parameters. +// Body parameters are excluded: they are already handled by the maps.Copy merge in flagOptions. +// For each unset flag, if the parsed data map contains a key matching the flag's QueryPath, HeaderPath, or +// PathParam (or any of its DataAliases), the flag is set to that value via flag.Set. +// +// Inner flags (those with an outer flag) are also handled: if the outer flag's body path key exists in the +// data map and contains a nested map with a key matching the inner flag's field (or aliases), the inner +// flag is set from that nested value. +func ApplyStdinDataToFlags(cmd *cli.Command, data map[string]any) error { + for _, flag := range cmd.Flags { + if flag.IsSet() { + continue + } + + // Handle inner flags: look for their value nested under the outer flag's body path. + if inner, ok := flag.(HasOuterFlag); ok { + outer, outerOk := inner.GetOuterFlag().(InRequest) + if !outerOk || outer.GetBodyPath() == "" { + continue + } + nested, ok := data[outer.GetBodyPath()].(map[string]any) + if !ok { + continue + } + innerField := inner.GetInnerField() + val, found := nested[innerField] + if !found { + for _, alias := range inner.GetDataAliases() { + if alias != "" && alias != innerField { + if v, ok := nested[alias]; ok { + val, found = v, true + break + } + } + } + } + if !found { + continue + } + setVal, err := formatForFlagSet(val) + if err != nil { + return fmt.Errorf("cannot format piped value for flag %q: %w", flag.Names()[0], err) + } + if err := flag.Set(flag.Names()[0], setVal); err != nil { + return fmt.Errorf("cannot set flag %q from piped data: %w", flag.Names()[0], err) + } + continue + } + + inReq, ok := flag.(InRequest) + if !ok { + continue + } + + // Try each request location in turn, checking the canonical path key and all aliases. + // Body params are excluded: they are already handled by the maps.Copy merge in flagOptions. + for _, path := range []string{inReq.GetQueryPath(), inReq.GetHeaderPath(), inReq.GetPathParam()} { + if path == "" { + continue + } + var val any + var found bool + for _, key := range append([]string{path}, inReq.GetDataAliases()...) { + if v, ok := data[key]; ok { + val, found = v, true + break + } + } + if !found { + continue + } + setVal, err := formatForFlagSet(val) + if err != nil { + return fmt.Errorf("cannot format piped value for flag %q: %w", flag.Names()[0], err) + } + if err := flag.Set(flag.Names()[0], setVal); err != nil { + return fmt.Errorf("cannot set flag %q from piped data: %w", flag.Names()[0], err) + } + break + } + } + return nil +} + func ExtractRequestContents(cmd *cli.Command) RequestContents { bodyMap := make(map[string]any) res := RequestContents{ @@ -291,7 +402,7 @@ func (f *Flag[T]) IsRequired() bool { } // Intentionally don't use `f.Required`, because request flags may be passed // over stdin as well as by flag. - if f.BodyPath != "" || f.BodyRoot { + if f.BodyPath != "" || f.BodyRoot || f.PathParam != "" || f.QueryPath != "" || f.HeaderPath != "" { return false } return f.Required diff --git a/internal/requestflag/requestflag_test.go b/internal/requestflag/requestflag_test.go index 06ffb72..779bd57 100644 --- a/internal/requestflag/requestflag_test.go +++ b/internal/requestflag/requestflag_test.go @@ -880,3 +880,348 @@ func TestInnerFlagDispatchOnUntypedFlag(t *testing.T) { assert.JSONEq(t, `{"foo":[{"name":"first","url":"https://example.com"}]}`, string(body)) }) } + +func TestApplyStdinDataToFlags(t *testing.T) { + t.Parallel() + + t.Run("sets query path flag from piped data", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"account_id": "acct_123"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, "acct_123", flag.Get()) + }) + + t.Run("sets header path flag from piped data", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "idempotency-key", + HeaderPath: "Idempotency-Key", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"Idempotency-Key": "key-xyz"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, "key-xyz", flag.Get()) + }) + + t.Run("does not set body path flag from piped data", func(t *testing.T) { + t.Parallel() + + // Body params are handled by the maps.Copy merge in flagOptions, not by ApplyStdinDataToFlags. + flag := &Flag[string]{ + Name: "message", + BodyPath: "message", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"message": "hello world"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, flag.IsSet()) + }) + + t.Run("does not override flag already set via CLI", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + } + assert.NoError(t, flag.PreParse()) + assert.NoError(t, flag.Set("account-id", "explicit_value")) + + data := map[string]any{"account_id": "piped_value"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + // The explicitly-set value should win. + assert.Equal(t, "explicit_value", flag.Get()) + }) + + t.Run("sets integer query flag from piped data", func(t *testing.T) { + t.Parallel() + + flag := &Flag[int64]{ + Name: "page-size", + QueryPath: "page_size", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"page_size": int64(50)} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, int64(50), flag.Get()) + }) + + t.Run("sets boolean query flag from piped data", func(t *testing.T) { + t.Parallel() + + flag := &Flag[bool]{ + Name: "include-deleted", + QueryPath: "include_deleted", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"include_deleted": true} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, true, flag.Get()) + }) + + t.Run("resolves query path flag via data alias", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + DataAliases: []string{"accountId", "account"}, + } + assert.NoError(t, flag.PreParse()) + + // Use one of the aliases as the key in piped data. + data := map[string]any{"accountId": "acct_alias"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, "acct_alias", flag.Get()) + }) + + t.Run("does not set body path flag via data alias", func(t *testing.T) { + t.Parallel() + + // Body params are handled by the maps.Copy merge in flagOptions, not by ApplyStdinDataToFlags. + flag := &Flag[string]{ + Name: "user-name", + BodyPath: "user_name", + DataAliases: []string{"userName", "username"}, + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"userName": "alice"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, flag.IsSet()) + }) + + t.Run("ignores flags with no matching key in piped data", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"other_key": "value"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, flag.IsSet()) + }) + + t.Run("ignores flags with no path set", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "some-flag", + // No QueryPath, HeaderPath, or BodyPath + } + assert.NoError(t, flag.PreParse()) + + data := map[string]any{"some-flag": "value"} + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, flag.IsSet()) + }) + + t.Run("handles multiple flags from piped data", func(t *testing.T) { + t.Parallel() + + accountFlag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + } + limitFlag := &Flag[int64]{ + Name: "limit", + QueryPath: "limit", + } + assert.NoError(t, accountFlag.PreParse()) + assert.NoError(t, limitFlag.PreParse()) + + data := map[string]any{ + "account_id": "acct_abc", + "limit": int64(25), + } + cmd := &cli.Command{Flags: []cli.Flag{accountFlag, limitFlag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, accountFlag.IsSet()) + assert.Equal(t, "acct_abc", accountFlag.Get()) + assert.True(t, limitFlag.IsSet()) + assert.Equal(t, int64(25), limitFlag.Get()) + }) + + t.Run("sets inner flag from nested piped data under outer body path", func(t *testing.T) { + t.Parallel() + + outer := &Flag[map[string]any]{ + Name: "address", + BodyPath: "address", + } + assert.NoError(t, outer.PreParse()) + + cityInner := &InnerFlag[string]{ + Name: "address.city", + InnerField: "city", + OuterFlag: outer, + } + + data := map[string]any{ + "address": map[string]any{"city": "San Francisco"}, + } + cmd := &cli.Command{Flags: []cli.Flag{outer, cityInner}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + // InnerFlag.IsSet() is always false by design; verify the value was written + // into the outer flag's underlying map instead. + outerVal, ok := outer.Get().(map[string]any) + assert.True(t, ok, "expected outer flag value to be map[string]any, got %T", outer.Get()) + assert.Equal(t, "San Francisco", outerVal["city"]) + }) + + t.Run("sets inner flag via data alias in nested piped data", func(t *testing.T) { + t.Parallel() + + outer := &Flag[map[string]any]{ + Name: "address", + BodyPath: "address", + } + assert.NoError(t, outer.PreParse()) + + cityInner := &InnerFlag[string]{ + Name: "address.city", + InnerField: "city", + DataAliases: []string{"cityName"}, + OuterFlag: outer, + } + + // Use the alias in piped data. + data := map[string]any{ + "address": map[string]any{"cityName": "Portland"}, + } + cmd := &cli.Command{Flags: []cli.Flag{outer, cityInner}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + // InnerFlag.IsSet() is always false by design; verify the value was written + // into the outer flag's underlying map instead. + outerVal, ok := outer.Get().(map[string]any) + assert.True(t, ok, "expected outer flag value to be map[string]any, got %T", outer.Get()) + assert.Equal(t, "Portland", outerVal["city"]) + }) + + t.Run("does not set inner flag when outer flag has no body path", func(t *testing.T) { + t.Parallel() + + outer := &Flag[map[string]any]{ + Name: "options", + // No BodyPath set + } + assert.NoError(t, outer.PreParse()) + + inner := &InnerFlag[string]{ + Name: "options.key", + InnerField: "key", + OuterFlag: outer, + } + + data := map[string]any{ + "options": map[string]any{"key": "value"}, + } + cmd := &cli.Command{Flags: []cli.Flag{outer, inner}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, inner.IsSet()) + }) + + t.Run("does not set inner flag when piped data has no nested map for outer path", func(t *testing.T) { + t.Parallel() + + outer := &Flag[map[string]any]{ + Name: "address", + BodyPath: "address", + } + assert.NoError(t, outer.PreParse()) + + inner := &InnerFlag[string]{ + Name: "address.city", + InnerField: "city", + OuterFlag: outer, + } + + // The outer body path key is missing from the piped data. + data := map[string]any{"other": "value"} + cmd := &cli.Command{Flags: []cli.Flag{outer, inner}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.False(t, inner.IsSet()) + }) + + t.Run("canonical path key takes precedence over alias when both are present", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + DataAliases: []string{"accountId"}, + } + assert.NoError(t, flag.PreParse()) + + // Both canonical and alias present — canonical should win because it's checked first. + data := map[string]any{ + "account_id": "canonical_value", + "accountId": "alias_value", + } + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, data)) + + assert.True(t, flag.IsSet()) + assert.Equal(t, "canonical_value", flag.Get()) + }) + + t.Run("empty data map does not set any flags", func(t *testing.T) { + t.Parallel() + + flag := &Flag[string]{ + Name: "account-id", + QueryPath: "account_id", + } + assert.NoError(t, flag.PreParse()) + + cmd := &cli.Command{Flags: []cli.Flag{flag}} + assert.NoError(t, ApplyStdinDataToFlags(cmd, map[string]any{})) + + assert.False(t, flag.IsSet()) + }) +} diff --git a/pkg/cmd/agent.go b/pkg/cmd/agent.go index 75f271a..40d9d01 100644 --- a/pkg/cmd/agent.go +++ b/pkg/cmd/agent.go @@ -60,8 +60,6 @@ func handleAgentSignUp(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.AgentSignUpParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -73,6 +71,8 @@ func handleAgentSignUp(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.AgentSignUpParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Agent.SignUp(ctx, params, options...) @@ -101,8 +101,6 @@ func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.AgentVerifyParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -114,6 +112,8 @@ func handleAgentVerify(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.AgentVerifyParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Agent.Verify(ctx, params, options...) diff --git a/pkg/cmd/apikey.go b/pkg/cmd/apikey.go index a1e4225..1f75a1e 100644 --- a/pkg/cmd/apikey.go +++ b/pkg/cmd/apikey.go @@ -243,9 +243,10 @@ var apiKeysDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "api-key-id", - Usage: "ID of api key.", - Required: true, + Name: "api-key-id", + Usage: "ID of api key.", + Required: true, + PathParam: "api_key_id", }, }, Action: handleAPIKeysDelete, @@ -260,8 +261,6 @@ func handleAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.APIKeyNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -273,6 +272,8 @@ func handleAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.APIKeyNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.APIKeys.New(ctx, params, options...) @@ -301,8 +302,6 @@ func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.APIKeyListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -314,6 +313,8 @@ func handleAPIKeysList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.APIKeyListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.APIKeys.List(ctx, params, options...) diff --git a/pkg/cmd/domain.go b/pkg/cmd/domain.go index 85af514..fe69bcd 100644 --- a/pkg/cmd/domain.go +++ b/pkg/cmd/domain.go @@ -42,9 +42,10 @@ var domainsUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, &requestflag.Flag[*bool]{ Name: "feedback-enabled", @@ -87,9 +88,10 @@ var domainsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handleDomainsDelete, @@ -102,9 +104,10 @@ var domainsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handleDomainsGet, @@ -117,9 +120,10 @@ var domainsGetZoneFile = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handleDomainsGetZoneFile, @@ -132,9 +136,10 @@ var domainsVerify = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handleDomainsVerify, @@ -149,8 +154,6 @@ func handleDomainsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.DomainNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -162,6 +165,8 @@ func handleDomainsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.DomainNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Domains.New(ctx, params, options...) @@ -193,8 +198,6 @@ func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.DomainUpdateParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -206,6 +209,8 @@ func handleDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.DomainUpdateParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Domains.Update( @@ -239,8 +244,6 @@ func handleDomainsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.DomainListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -252,6 +255,8 @@ func handleDomainsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.DomainListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Domains.List(ctx, params, options...) diff --git a/pkg/cmd/draft.go b/pkg/cmd/draft.go index 3d79ad0..b105d8a 100644 --- a/pkg/cmd/draft.go +++ b/pkg/cmd/draft.go @@ -60,9 +60,10 @@ var draftsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, }, Action: handleDraftsGet, @@ -75,14 +76,16 @@ var draftsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handleDraftsGetAttachment, @@ -97,8 +100,6 @@ func handleDraftsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.DraftListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -110,6 +111,8 @@ func handleDraftsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.DraftListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Drafts.List(ctx, params, options...) @@ -183,10 +186,6 @@ func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.DraftGetAttachmentParams{ - DraftID: cmd.Value("draft-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -198,6 +197,10 @@ func handleDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.DraftGetAttachmentParams{ + DraftID: cmd.Value("draft-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Drafts.GetAttachment( diff --git a/pkg/cmd/flagoptions.go b/pkg/cmd/flagoptions.go index 8ad5f59..db43a15 100644 --- a/pkg/cmd/flagoptions.go +++ b/pkg/cmd/flagoptions.go @@ -339,7 +339,7 @@ func flagOptions( } stdinConsumedByPipe := false - if (bodyType == MultipartFormEncoded || bodyType == ApplicationJSON) && !ignoreStdin && isInputPiped() { + if bodyType != ApplicationOctetStream && !ignoreStdin && isInputPiped() { pipeData, err := io.ReadAll(os.Stdin) if err != nil { return nil, err @@ -353,16 +353,45 @@ func flagOptions( } if bodyMap, ok := bodyData.(map[string]any); ok { applyDataAliases(cmd, bodyMap) - if flagMap, ok := requestContents.Body.(map[string]any); ok { - maps.Copy(bodyMap, flagMap) - requestContents.Body = bodyMap + // Apply any matching keys from the piped data to path, query, and header flags + // that have not already been set via the command line. + if err := requestflag.ApplyStdinDataToFlags(cmd, bodyMap); err != nil { + return nil, err + } + // Re-extract request contents now that flags may have been updated. + requestContents = requestflag.ExtractRequestContents(cmd) + // Remove keys that were consumed as query, header, or path params so they + // don't also leak into the request body via the maps.Copy merge below. + // We delete both the canonical key and any aliases since the user may have + // piped data using an alias name rather than the canonical API name. + for _, flag := range cmd.Flags { + inReq, ok := flag.(requestflag.InRequest) + if !ok || !flag.IsSet() { + continue + } + if inReq.GetQueryPath() != "" || inReq.GetHeaderPath() != "" || inReq.GetPathParam() != "" { + delete(bodyMap, inReq.GetQueryPath()) + delete(bodyMap, inReq.GetHeaderPath()) + delete(bodyMap, inReq.GetPathParam()) + for _, alias := range inReq.GetDataAliases() { + delete(bodyMap, alias) + } + } + } + if bodyType != EmptyBody { + if flagMap, ok := requestContents.Body.(map[string]any); ok { + maps.Copy(bodyMap, flagMap) + requestContents.Body = bodyMap + } else { + bodyData = requestContents.Body + } + } + } else if bodyType != EmptyBody { + if flagMap, ok := requestContents.Body.(map[string]any); ok && len(flagMap) > 0 { + return nil, fmt.Errorf("Cannot merge flags with a body that is not a map: %v", bodyData) } else { - bodyData = requestContents.Body + requestContents.Body = bodyData } - } else if flagMap, ok := requestContents.Body.(map[string]any); ok && len(flagMap) > 0 { - return nil, fmt.Errorf("Cannot merge flags with a body that is not a map: %v", bodyData) - } else { - requestContents.Body = bodyData } } } @@ -370,7 +399,6 @@ func flagOptions( if missingFlags := requestflag.GetMissingRequiredFlags(cmd, requestContents.Body); len(missingFlags) > 0 { if len(missingFlags) == 1 { return nil, fmt.Errorf("Required flag %q not set\nRun '%s --help' for usage information", missingFlags[0].Names()[0], cmd.FullName()) - } else { names := []string{} for _, flag := range missingFlags { diff --git a/pkg/cmd/inbox.go b/pkg/cmd/inbox.go index 8c94641..c6956ad 100644 --- a/pkg/cmd/inbox.go +++ b/pkg/cmd/inbox.go @@ -50,9 +50,10 @@ var inboxesUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ Name: "display-name", @@ -96,9 +97,10 @@ var inboxesDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, }, Action: handleInboxesDelete, @@ -111,9 +113,10 @@ var inboxesGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, }, Action: handleInboxesGet, @@ -126,9 +129,10 @@ var inboxesListMetrics = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[*bool]{ Name: "descending", @@ -173,8 +177,6 @@ func handleInboxesCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -186,6 +188,8 @@ func handleInboxesCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.New(ctx, params, options...) @@ -217,8 +221,6 @@ func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxUpdateParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -230,6 +232,8 @@ func handleInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxUpdateParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Update( @@ -263,8 +267,6 @@ func handleInboxesList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -276,6 +278,8 @@ func handleInboxesList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.List(ctx, params, options...) @@ -374,8 +378,6 @@ func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListMetricsParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -387,6 +389,8 @@ func handleInboxesListMetrics(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListMetricsParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.ListMetrics( diff --git a/pkg/cmd/inboxapikey.go b/pkg/cmd/inboxapikey.go index 49fe56a..4478dd7 100644 --- a/pkg/cmd/inboxapikey.go +++ b/pkg/cmd/inboxapikey.go @@ -20,9 +20,10 @@ var inboxesAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[*string]{ Name: "name", @@ -223,9 +224,10 @@ var inboxesAPIKeysList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[*int64]{ Name: "limit", @@ -248,14 +250,16 @@ var inboxesAPIKeysDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "api-key-id", - Usage: "ID of api key.", - Required: true, + Name: "api-key-id", + Usage: "ID of api key.", + Required: true, + PathParam: "api_key_id", }, }, Action: handleInboxesAPIKeysDelete, @@ -273,8 +277,6 @@ func handleInboxesAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxAPIKeyNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -286,6 +288,8 @@ func handleInboxesAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxAPIKeyNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.APIKeys.New( @@ -322,8 +326,6 @@ func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxAPIKeyListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -335,6 +337,8 @@ func handleInboxesAPIKeysList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxAPIKeyListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.APIKeys.List( @@ -371,10 +375,6 @@ func handleInboxesAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxAPIKeyDeleteParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -386,6 +386,10 @@ func handleInboxesAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxAPIKeyDeleteParams{ + InboxID: cmd.Value("inbox-id").(string), + } + return client.Inboxes.APIKeys.Delete( ctx, cmd.Value("api-key-id").(string), diff --git a/pkg/cmd/inboxdraft.go b/pkg/cmd/inboxdraft.go index 7e3186c..6aa1b99 100644 --- a/pkg/cmd/inboxdraft.go +++ b/pkg/cmd/inboxdraft.go @@ -20,9 +20,10 @@ var inboxesDraftsCreate = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[any]{ Name: "attachment", @@ -134,14 +135,16 @@ var inboxesDraftsUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, &requestflag.Flag[any]{ Name: "bcc", @@ -194,9 +197,10 @@ var inboxesDraftsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[any]{ Name: "after", @@ -239,14 +243,16 @@ var inboxesDraftsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, }, Action: handleInboxesDraftsDelete, @@ -259,14 +265,16 @@ var inboxesDraftsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, }, Action: handleInboxesDraftsGet, @@ -279,19 +287,22 @@ var inboxesDraftsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handleInboxesDraftsGetAttachment, @@ -304,14 +315,16 @@ var inboxesDraftsSend = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, &requestflag.Flag[any]{ Name: "add-labels", @@ -339,8 +352,6 @@ func handleInboxesDraftsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -352,6 +363,8 @@ func handleInboxesDraftsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.New( @@ -388,10 +401,6 @@ func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftUpdateParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -403,6 +412,10 @@ func handleInboxesDraftsUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftUpdateParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.Update( @@ -439,8 +452,6 @@ func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -452,6 +463,8 @@ func handleInboxesDraftsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.List( @@ -488,10 +501,6 @@ func handleInboxesDraftsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftDeleteParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -503,6 +512,10 @@ func handleInboxesDraftsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftDeleteParams{ + InboxID: cmd.Value("inbox-id").(string), + } + return client.Inboxes.Drafts.Delete( ctx, cmd.Value("draft-id").(string), @@ -522,10 +535,6 @@ func handleInboxesDraftsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftGetParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -537,6 +546,10 @@ func handleInboxesDraftsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftGetParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.Get( @@ -573,11 +586,6 @@ func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) err return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftGetAttachmentParams{ - InboxID: cmd.Value("inbox-id").(string), - DraftID: cmd.Value("draft-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -589,6 +597,11 @@ func handleInboxesDraftsGetAttachment(ctx context.Context, cmd *cli.Command) err return err } + params := agentmail.InboxDraftGetAttachmentParams{ + InboxID: cmd.Value("inbox-id").(string), + DraftID: cmd.Value("draft-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.GetAttachment( @@ -625,10 +638,6 @@ func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxDraftSendParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -640,6 +649,10 @@ func handleInboxesDraftsSend(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxDraftSendParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Drafts.Send( diff --git a/pkg/cmd/inboxlist.go b/pkg/cmd/inboxlist.go index 8a7de73..f926f49 100644 --- a/pkg/cmd/inboxlist.go +++ b/pkg/cmd/inboxlist.go @@ -20,19 +20,22 @@ var inboxesListsCreate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ Name: "entry", @@ -56,19 +59,22 @@ var inboxesListsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[*int64]{ Name: "limit", @@ -91,23 +97,27 @@ var inboxesListsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handleInboxesListsDelete, @@ -120,23 +130,27 @@ var inboxesListsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handleInboxesListsGet, @@ -154,11 +168,6 @@ func handleInboxesListsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListNewParams{ - InboxID: cmd.Value("inbox-id").(string), - Direction: agentmail.InboxListNewParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -170,6 +179,11 @@ func handleInboxesListsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListNewParams{ + InboxID: cmd.Value("inbox-id").(string), + Direction: agentmail.InboxListNewParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Lists.New( @@ -206,11 +220,6 @@ func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListListParams{ - InboxID: cmd.Value("inbox-id").(string), - Direction: agentmail.InboxListListParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -222,6 +231,11 @@ func handleInboxesListsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListListParams{ + InboxID: cmd.Value("inbox-id").(string), + Direction: agentmail.InboxListListParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Lists.List( @@ -258,12 +272,6 @@ func handleInboxesListsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListDeleteParams{ - InboxID: cmd.Value("inbox-id").(string), - Direction: agentmail.InboxListDeleteParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.InboxListDeleteParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -275,6 +283,12 @@ func handleInboxesListsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListDeleteParams{ + InboxID: cmd.Value("inbox-id").(string), + Direction: agentmail.InboxListDeleteParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.InboxListDeleteParamsType(cmd.Value("type").(string)), + } + return client.Inboxes.Lists.Delete( ctx, cmd.Value("entry").(string), @@ -294,12 +308,6 @@ func handleInboxesListsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxListGetParams{ - InboxID: cmd.Value("inbox-id").(string), - Direction: agentmail.InboxListGetParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.InboxListGetParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -311,6 +319,12 @@ func handleInboxesListsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxListGetParams{ + InboxID: cmd.Value("inbox-id").(string), + Direction: agentmail.InboxListGetParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.InboxListGetParamsType(cmd.Value("type").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Lists.Get( diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index ec9078f..078025a 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -20,14 +20,16 @@ var inboxesMessagesUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, &requestflag.Flag[any]{ Name: "add-labels", @@ -50,9 +52,10 @@ var inboxesMessagesList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[any]{ Name: "after", @@ -110,14 +113,16 @@ var inboxesMessagesForward = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, &requestflag.Flag[any]{ Name: "attachment", @@ -215,14 +220,16 @@ var inboxesMessagesGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, }, Action: handleInboxesMessagesGet, @@ -235,19 +242,22 @@ var inboxesMessagesGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handleInboxesMessagesGetAttachment, @@ -260,14 +270,16 @@ var inboxesMessagesGetRaw = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, }, Action: handleInboxesMessagesGetRaw, @@ -280,14 +292,16 @@ var inboxesMessagesReply = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, &requestflag.Flag[any]{ Name: "attachment", @@ -385,14 +399,16 @@ var inboxesMessagesReplyAll = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "message-id", - Usage: "ID of message.", - Required: true, + Name: "message-id", + Usage: "ID of message.", + Required: true, + PathParam: "message_id", }, &requestflag.Flag[any]{ Name: "attachment", @@ -473,9 +489,10 @@ var inboxesMessagesSend = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[any]{ Name: "attachment", @@ -578,10 +595,6 @@ func handleInboxesMessagesUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageUpdateParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -593,6 +606,10 @@ func handleInboxesMessagesUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageUpdateParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.Update( @@ -629,8 +646,6 @@ func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -642,6 +657,8 @@ func handleInboxesMessagesList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.List( @@ -678,10 +695,6 @@ func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageForwardParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -693,6 +706,10 @@ func handleInboxesMessagesForward(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageForwardParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.Forward( @@ -729,10 +746,6 @@ func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageGetParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -744,6 +757,10 @@ func handleInboxesMessagesGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageGetParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.Get( @@ -780,11 +797,6 @@ func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) e return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageGetAttachmentParams{ - InboxID: cmd.Value("inbox-id").(string), - MessageID: cmd.Value("message-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -796,6 +808,11 @@ func handleInboxesMessagesGetAttachment(ctx context.Context, cmd *cli.Command) e return err } + params := agentmail.InboxMessageGetAttachmentParams{ + InboxID: cmd.Value("inbox-id").(string), + MessageID: cmd.Value("message-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.GetAttachment( @@ -832,10 +849,6 @@ func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageGetRawParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -847,6 +860,10 @@ func handleInboxesMessagesGetRaw(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageGetRawParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.GetRaw( @@ -883,10 +900,6 @@ func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageReplyParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -898,6 +911,10 @@ func handleInboxesMessagesReply(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageReplyParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.Reply( @@ -934,10 +951,6 @@ func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageReplyAllParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -949,6 +962,10 @@ func handleInboxesMessagesReplyAll(ctx context.Context, cmd *cli.Command) error return err } + params := agentmail.InboxMessageReplyAllParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.ReplyAll( @@ -985,8 +1002,6 @@ func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxMessageSendParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -998,6 +1013,8 @@ func handleInboxesMessagesSend(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxMessageSendParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Messages.Send( diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index 2de33ec..9256ed0 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -20,9 +20,10 @@ var inboxesThreadsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[any]{ Name: "after", @@ -80,14 +81,16 @@ var inboxesThreadsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[*bool]{ Name: "permanent", @@ -105,14 +108,16 @@ var inboxesThreadsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, }, Action: handleInboxesThreadsGet, @@ -125,19 +130,22 @@ var inboxesThreadsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handleInboxesThreadsGetAttachment, @@ -155,8 +163,6 @@ func handleInboxesThreadsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxThreadListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -168,6 +174,8 @@ func handleInboxesThreadsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxThreadListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Threads.List( @@ -204,10 +212,6 @@ func handleInboxesThreadsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxThreadDeleteParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -219,6 +223,10 @@ func handleInboxesThreadsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxThreadDeleteParams{ + InboxID: cmd.Value("inbox-id").(string), + } + return client.Inboxes.Threads.Delete( ctx, cmd.Value("thread-id").(string), @@ -238,10 +246,6 @@ func handleInboxesThreadsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxThreadGetParams{ - InboxID: cmd.Value("inbox-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -253,6 +257,10 @@ func handleInboxesThreadsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.InboxThreadGetParams{ + InboxID: cmd.Value("inbox-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Threads.Get( @@ -289,11 +297,6 @@ func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) er return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.InboxThreadGetAttachmentParams{ - InboxID: cmd.Value("inbox-id").(string), - ThreadID: cmd.Value("thread-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -305,6 +308,11 @@ func handleInboxesThreadsGetAttachment(ctx context.Context, cmd *cli.Command) er return err } + params := agentmail.InboxThreadGetAttachmentParams{ + InboxID: cmd.Value("inbox-id").(string), + ThreadID: cmd.Value("thread-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Inboxes.Threads.GetAttachment( diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 99c647a..3431bfd 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -20,14 +20,16 @@ var listsCreate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ Name: "entry", @@ -51,14 +53,16 @@ var listsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[*int64]{ Name: "limit", @@ -81,18 +85,21 @@ var listsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handleListsDelete, @@ -105,18 +112,21 @@ var listsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handleListsGet, @@ -134,10 +144,6 @@ func handleListsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ListNewParams{ - Direction: agentmail.ListNewParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -149,6 +155,10 @@ func handleListsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ListNewParams{ + Direction: agentmail.ListNewParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Lists.New( @@ -185,10 +195,6 @@ func handleListsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ListListParams{ - Direction: agentmail.ListListParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -200,6 +206,10 @@ func handleListsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ListListParams{ + Direction: agentmail.ListListParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Lists.List( @@ -236,11 +246,6 @@ func handleListsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ListDeleteParams{ - Direction: agentmail.ListDeleteParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.ListDeleteParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -252,6 +257,11 @@ func handleListsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ListDeleteParams{ + Direction: agentmail.ListDeleteParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.ListDeleteParamsType(cmd.Value("type").(string)), + } + return client.Lists.Delete( ctx, cmd.Value("entry").(string), @@ -271,11 +281,6 @@ func handleListsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ListGetParams{ - Direction: agentmail.ListGetParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.ListGetParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -287,6 +292,11 @@ func handleListsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ListGetParams{ + Direction: agentmail.ListGetParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.ListGetParamsType(cmd.Value("type").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Lists.Get( diff --git a/pkg/cmd/metric.go b/pkg/cmd/metric.go index 550eaa3..267ee13 100644 --- a/pkg/cmd/metric.go +++ b/pkg/cmd/metric.go @@ -62,8 +62,6 @@ func handleMetricsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.MetricListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -75,6 +73,8 @@ func handleMetricsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.MetricListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Metrics.List(ctx, params, options...) diff --git a/pkg/cmd/pod.go b/pkg/cmd/pod.go index 9a2a717..59e8f7b 100644 --- a/pkg/cmd/pod.go +++ b/pkg/cmd/pod.go @@ -65,9 +65,10 @@ var podsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, }, Action: handlePodsDelete, @@ -80,9 +81,10 @@ var podsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, }, Action: handlePodsGet, @@ -97,8 +99,6 @@ func handlePodsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -110,6 +110,8 @@ func handlePodsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.New(ctx, params, options...) @@ -138,8 +140,6 @@ func handlePodsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -151,6 +151,8 @@ func handlePodsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.List(ctx, params, options...) diff --git a/pkg/cmd/podapikey.go b/pkg/cmd/podapikey.go index 84a9ad8..ff85ae4 100644 --- a/pkg/cmd/podapikey.go +++ b/pkg/cmd/podapikey.go @@ -20,9 +20,10 @@ var podsAPIKeysCreate = requestflag.WithInnerFlags(cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*string]{ Name: "name", @@ -223,9 +224,10 @@ var podsAPIKeysList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*int64]{ Name: "limit", @@ -248,14 +250,16 @@ var podsAPIKeysDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "api-key-id", - Usage: "ID of api key.", - Required: true, + Name: "api-key-id", + Usage: "ID of api key.", + Required: true, + PathParam: "api_key_id", }, }, Action: handlePodsAPIKeysDelete, @@ -273,8 +277,6 @@ func handlePodsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodAPIKeyNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -286,6 +288,8 @@ func handlePodsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodAPIKeyNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.APIKeys.New( @@ -322,8 +326,6 @@ func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodAPIKeyListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -335,6 +337,8 @@ func handlePodsAPIKeysList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodAPIKeyListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.APIKeys.List( @@ -371,10 +375,6 @@ func handlePodsAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodAPIKeyDeleteParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -386,6 +386,10 @@ func handlePodsAPIKeysDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodAPIKeyDeleteParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.APIKeys.Delete( ctx, cmd.Value("api-key-id").(string), diff --git a/pkg/cmd/poddomain.go b/pkg/cmd/poddomain.go index d25e0f4..61083cd 100644 --- a/pkg/cmd/poddomain.go +++ b/pkg/cmd/poddomain.go @@ -20,9 +20,10 @@ var podsDomainsCreate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ Name: "domain", @@ -47,14 +48,16 @@ var podsDomainsUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, &requestflag.Flag[*bool]{ Name: "feedback-enabled", @@ -72,9 +75,10 @@ var podsDomainsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*bool]{ Name: "ascending", @@ -102,14 +106,16 @@ var podsDomainsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handlePodsDomainsDelete, @@ -122,14 +128,16 @@ var podsDomainsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handlePodsDomainsGet, @@ -142,14 +150,16 @@ var podsDomainsGetZoneFile = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handlePodsDomainsGetZoneFile, @@ -162,14 +172,16 @@ var podsDomainsVerify = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "domain-id", - Usage: "The ID of the domain.", - Required: true, + Name: "domain-id", + Usage: "The ID of the domain.", + Required: true, + PathParam: "domain_id", }, }, Action: handlePodsDomainsVerify, @@ -187,8 +199,6 @@ func handlePodsDomainsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -200,6 +210,8 @@ func handlePodsDomainsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Domains.New( @@ -236,10 +248,6 @@ func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainUpdateParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -251,6 +259,10 @@ func handlePodsDomainsUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainUpdateParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Domains.Update( @@ -287,8 +299,6 @@ func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -300,6 +310,8 @@ func handlePodsDomainsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Domains.List( @@ -336,10 +348,6 @@ func handlePodsDomainsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainDeleteParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -351,6 +359,10 @@ func handlePodsDomainsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainDeleteParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.Domains.Delete( ctx, cmd.Value("domain-id").(string), @@ -370,10 +382,6 @@ func handlePodsDomainsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainGetParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -385,6 +393,10 @@ func handlePodsDomainsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainGetParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Domains.Get( @@ -421,10 +433,6 @@ func handlePodsDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainGetZoneFileParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -436,6 +444,10 @@ func handlePodsDomainsGetZoneFile(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainGetZoneFileParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.Domains.GetZoneFile( ctx, cmd.Value("domain-id").(string), @@ -455,10 +467,6 @@ func handlePodsDomainsVerify(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDomainVerifyParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -470,6 +478,10 @@ func handlePodsDomainsVerify(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDomainVerifyParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.Domains.Verify( ctx, cmd.Value("domain-id").(string), diff --git a/pkg/cmd/poddraft.go b/pkg/cmd/poddraft.go index 3b5378c..ae61c90 100644 --- a/pkg/cmd/poddraft.go +++ b/pkg/cmd/poddraft.go @@ -20,9 +20,10 @@ var podsDraftsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[any]{ Name: "after", @@ -65,14 +66,16 @@ var podsDraftsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, }, Action: handlePodsDraftsGet, @@ -85,19 +88,22 @@ var podsDraftsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "draft-id", - Usage: "ID of draft.", - Required: true, + Name: "draft-id", + Usage: "ID of draft.", + Required: true, + PathParam: "draft_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handlePodsDraftsGetAttachment, @@ -115,8 +121,6 @@ func handlePodsDraftsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDraftListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -128,6 +132,8 @@ func handlePodsDraftsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDraftListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Drafts.List( @@ -164,10 +170,6 @@ func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDraftGetParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -179,6 +181,10 @@ func handlePodsDraftsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodDraftGetParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Drafts.Get( @@ -215,11 +221,6 @@ func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodDraftGetAttachmentParams{ - PodID: cmd.Value("pod-id").(string), - DraftID: cmd.Value("draft-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -231,6 +232,11 @@ func handlePodsDraftsGetAttachment(ctx context.Context, cmd *cli.Command) error return err } + params := agentmail.PodDraftGetAttachmentParams{ + PodID: cmd.Value("pod-id").(string), + DraftID: cmd.Value("draft-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Drafts.GetAttachment( diff --git a/pkg/cmd/podinbox.go b/pkg/cmd/podinbox.go index c266eea..e7c797d 100644 --- a/pkg/cmd/podinbox.go +++ b/pkg/cmd/podinbox.go @@ -20,9 +20,10 @@ var podsInboxesCreate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*string]{ Name: "client-id", @@ -55,14 +56,16 @@ var podsInboxesUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, &requestflag.Flag[string]{ Name: "display-name", @@ -81,9 +84,10 @@ var podsInboxesList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*bool]{ Name: "ascending", @@ -111,14 +115,16 @@ var podsInboxesDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, }, Action: handlePodsInboxesDelete, @@ -131,14 +137,16 @@ var podsInboxesGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "inbox-id", - Usage: "The ID of the inbox.", - Required: true, + Name: "inbox-id", + Usage: "The ID of the inbox.", + Required: true, + PathParam: "inbox_id", }, }, Action: handlePodsInboxesGet, @@ -156,8 +164,6 @@ func handlePodsInboxesCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodInboxNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -169,6 +175,8 @@ func handlePodsInboxesCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodInboxNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Inboxes.New( @@ -205,10 +213,6 @@ func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodInboxUpdateParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -220,6 +224,10 @@ func handlePodsInboxesUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodInboxUpdateParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Inboxes.Update( @@ -256,8 +264,6 @@ func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodInboxListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -269,6 +275,8 @@ func handlePodsInboxesList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodInboxListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Inboxes.List( @@ -305,10 +313,6 @@ func handlePodsInboxesDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodInboxDeleteParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -320,6 +324,10 @@ func handlePodsInboxesDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodInboxDeleteParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.Inboxes.Delete( ctx, cmd.Value("inbox-id").(string), @@ -339,10 +347,6 @@ func handlePodsInboxesGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodInboxGetParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -354,6 +358,10 @@ func handlePodsInboxesGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodInboxGetParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Inboxes.Get( diff --git a/pkg/cmd/podlist.go b/pkg/cmd/podlist.go index da488ee..c720b84 100644 --- a/pkg/cmd/podlist.go +++ b/pkg/cmd/podlist.go @@ -20,19 +20,22 @@ var podsListsCreate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ Name: "entry", @@ -56,19 +59,22 @@ var podsListsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[*int64]{ Name: "limit", @@ -91,23 +97,27 @@ var podsListsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handlePodsListsDelete, @@ -120,23 +130,27 @@ var podsListsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "direction", - Usage: "Direction of list entry.", - Required: true, + Name: "direction", + Usage: "Direction of list entry.", + Required: true, + PathParam: "direction", }, &requestflag.Flag[string]{ - Name: "type", - Usage: "Type of list entry.", - Required: true, + Name: "type", + Usage: "Type of list entry.", + Required: true, + PathParam: "type", }, &requestflag.Flag[string]{ - Name: "entry", - Required: true, + Name: "entry", + Required: true, + PathParam: "entry", }, }, Action: handlePodsListsGet, @@ -154,11 +168,6 @@ func handlePodsListsCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodListNewParams{ - PodID: cmd.Value("pod-id").(string), - Direction: agentmail.PodListNewParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -170,6 +179,11 @@ func handlePodsListsCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodListNewParams{ + PodID: cmd.Value("pod-id").(string), + Direction: agentmail.PodListNewParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Lists.New( @@ -206,11 +220,6 @@ func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodListListParams{ - PodID: cmd.Value("pod-id").(string), - Direction: agentmail.PodListListParamsDirection(cmd.Value("direction").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -222,6 +231,11 @@ func handlePodsListsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodListListParams{ + PodID: cmd.Value("pod-id").(string), + Direction: agentmail.PodListListParamsDirection(cmd.Value("direction").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Lists.List( @@ -258,12 +272,6 @@ func handlePodsListsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodListDeleteParams{ - PodID: cmd.Value("pod-id").(string), - Direction: agentmail.PodListDeleteParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.PodListDeleteParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -275,6 +283,12 @@ func handlePodsListsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodListDeleteParams{ + PodID: cmd.Value("pod-id").(string), + Direction: agentmail.PodListDeleteParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.PodListDeleteParamsType(cmd.Value("type").(string)), + } + return client.Pods.Lists.Delete( ctx, cmd.Value("entry").(string), @@ -294,12 +308,6 @@ func handlePodsListsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodListGetParams{ - PodID: cmd.Value("pod-id").(string), - Direction: agentmail.PodListGetParamsDirection(cmd.Value("direction").(string)), - Type: agentmail.PodListGetParamsType(cmd.Value("type").(string)), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -311,6 +319,12 @@ func handlePodsListsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodListGetParams{ + PodID: cmd.Value("pod-id").(string), + Direction: agentmail.PodListGetParamsDirection(cmd.Value("direction").(string)), + Type: agentmail.PodListGetParamsType(cmd.Value("type").(string)), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Lists.Get( diff --git a/pkg/cmd/podmetric.go b/pkg/cmd/podmetric.go index d1afc62..99c857d 100644 --- a/pkg/cmd/podmetric.go +++ b/pkg/cmd/podmetric.go @@ -20,9 +20,10 @@ var podsMetricsQuery = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[*bool]{ Name: "descending", @@ -70,8 +71,6 @@ func handlePodsMetricsQuery(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodMetricQueryParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -83,6 +82,8 @@ func handlePodsMetricsQuery(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodMetricQueryParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Metrics.Query( diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index 23834a6..cb3cbdf 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -20,9 +20,10 @@ var podsThreadsList = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[any]{ Name: "after", @@ -80,14 +81,16 @@ var podsThreadsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[*bool]{ Name: "permanent", @@ -105,14 +108,16 @@ var podsThreadsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, }, Action: handlePodsThreadsGet, @@ -125,19 +130,22 @@ var podsThreadsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "pod-id", - Usage: "ID of pod.", - Required: true, + Name: "pod-id", + Usage: "ID of pod.", + Required: true, + PathParam: "pod_id", }, &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handlePodsThreadsGetAttachment, @@ -155,8 +163,6 @@ func handlePodsThreadsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodThreadListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -168,6 +174,8 @@ func handlePodsThreadsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodThreadListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Threads.List( @@ -204,10 +212,6 @@ func handlePodsThreadsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodThreadDeleteParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -219,6 +223,10 @@ func handlePodsThreadsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodThreadDeleteParams{ + PodID: cmd.Value("pod-id").(string), + } + return client.Pods.Threads.Delete( ctx, cmd.Value("thread-id").(string), @@ -238,10 +246,6 @@ func handlePodsThreadsGet(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodThreadGetParams{ - PodID: cmd.Value("pod-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -253,6 +257,10 @@ func handlePodsThreadsGet(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.PodThreadGetParams{ + PodID: cmd.Value("pod-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Threads.Get( @@ -289,11 +297,6 @@ func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.PodThreadGetAttachmentParams{ - PodID: cmd.Value("pod-id").(string), - ThreadID: cmd.Value("thread-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -305,6 +308,11 @@ func handlePodsThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error return err } + params := agentmail.PodThreadGetAttachmentParams{ + PodID: cmd.Value("pod-id").(string), + ThreadID: cmd.Value("thread-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Pods.Threads.GetAttachment( diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index dbc0a6a..031e1fe 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -75,9 +75,10 @@ var threadsDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[*bool]{ Name: "permanent", @@ -95,9 +96,10 @@ var threadsGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, }, Action: handleThreadsGet, @@ -110,14 +112,16 @@ var threadsGetAttachment = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "thread-id", - Usage: "ID of thread.", - Required: true, + Name: "thread-id", + Usage: "ID of thread.", + Required: true, + PathParam: "thread_id", }, &requestflag.Flag[string]{ - Name: "attachment-id", - Usage: "ID of attachment.", - Required: true, + Name: "attachment-id", + Usage: "ID of attachment.", + Required: true, + PathParam: "attachment_id", }, }, Action: handleThreadsGetAttachment, @@ -132,8 +136,6 @@ func handleThreadsList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ThreadListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -145,6 +147,8 @@ func handleThreadsList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ThreadListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Threads.List(ctx, params, options...) @@ -176,8 +180,6 @@ func handleThreadsDelete(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ThreadDeleteParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -189,6 +191,8 @@ func handleThreadsDelete(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ThreadDeleteParams{} + return client.Threads.Delete( ctx, cmd.Value("thread-id").(string), @@ -250,10 +254,6 @@ func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.ThreadGetAttachmentParams{ - ThreadID: cmd.Value("thread-id").(string), - } - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -265,6 +265,10 @@ func handleThreadsGetAttachment(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.ThreadGetAttachmentParams{ + ThreadID: cmd.Value("thread-id").(string), + } + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Threads.GetAttachment( diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index 2121faa..0ea6a4f 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -57,9 +57,10 @@ var webhooksUpdate = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "webhook-id", - Usage: "ID of webhook.", - Required: true, + Name: "webhook-id", + Usage: "ID of webhook.", + Required: true, + PathParam: "webhook_id", }, &requestflag.Flag[any]{ Name: "add-inbox-id", @@ -117,9 +118,10 @@ var webhooksDelete = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "webhook-id", - Usage: "ID of webhook.", - Required: true, + Name: "webhook-id", + Usage: "ID of webhook.", + Required: true, + PathParam: "webhook_id", }, }, Action: handleWebhooksDelete, @@ -132,9 +134,10 @@ var webhooksGet = cli.Command{ Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ - Name: "webhook-id", - Usage: "ID of webhook.", - Required: true, + Name: "webhook-id", + Usage: "ID of webhook.", + Required: true, + PathParam: "webhook_id", }, }, Action: handleWebhooksGet, @@ -149,8 +152,6 @@ func handleWebhooksCreate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.WebhookNewParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -162,6 +163,8 @@ func handleWebhooksCreate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.WebhookNewParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Webhooks.New(ctx, params, options...) @@ -193,8 +196,6 @@ func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.WebhookUpdateParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -206,6 +207,8 @@ func handleWebhooksUpdate(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.WebhookUpdateParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Webhooks.Update( @@ -239,8 +242,6 @@ func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) } - params := agentmail.WebhookListParams{} - options, err := flagOptions( cmd, apiquery.NestedQueryFormatBrackets, @@ -252,6 +253,8 @@ func handleWebhooksList(ctx context.Context, cmd *cli.Command) error { return err } + params := agentmail.WebhookListParams{} + var res []byte options = append(options, option.WithResponseBodyInto(&res)) _, err = client.Webhooks.List(ctx, params, options...) From 0d32710a2ceab83a7046697ffb2b724fbfdb6e8a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 04:05:08 +0000 Subject: [PATCH 20/31] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2cd935c..1cac1d3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-c97dd45dc91d256d4a19c2d7ca44cc45acdc7f4c6e30a9e3ffb7f70d052e404e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-4207a47659f20a32b4dbc146380b9414d0345006ac115d3b7c00b24de15eace9.yml openapi_spec_hash: 485c40cab6b7ae69327ddc44a2ff82c9 config_hash: 8ab5eb1bfc282411f0283d386a319f23 From 42b296accc273d1f43984b7a978500f5f4c890fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 21:13:48 +0000 Subject: [PATCH 21/31] feat(api): api update --- .stats.yml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/cmd/inboxmessage.go | 5 +++++ pkg/cmd/inboxmessage_test.go | 1 + pkg/cmd/inboxthread.go | 5 +++++ pkg/cmd/inboxthread_test.go | 1 + pkg/cmd/podthread.go | 5 +++++ pkg/cmd/podthread_test.go | 1 + pkg/cmd/thread.go | 5 +++++ pkg/cmd/thread_test.go | 1 + 11 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1cac1d3..6d38055 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-4207a47659f20a32b4dbc146380b9414d0345006ac115d3b7c00b24de15eace9.yml -openapi_spec_hash: 485c40cab6b7ae69327ddc44a2ff82c9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-a891f5285b07e5b0a91547cce9635fcb7da35952d178427343230e2eb17fc5a1.yml +openapi_spec_hash: 5c6ec5f8ecc60c5c22be81a5e6fbb895 config_hash: 8ab5eb1bfc282411f0283d386a319f23 diff --git a/go.mod b/go.mod index fec3e09..ee5f017 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.10.0 + github.com/agentmail-to/agentmail-go v0.10.1 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index d7930d9..ef57205 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.10.0 h1:seHlvGOojKTO+mkdQLULm1G9NTQNh+sdPjXTySheQQE= -github.com/agentmail-to/agentmail-go v0.10.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.10.1 h1:gwFSKxKeNswKI4lvSU8ZYZlCCJ+lJxWGN0eOunxMgTM= +github.com/agentmail-to/agentmail-go v0.10.1/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= diff --git a/pkg/cmd/inboxmessage.go b/pkg/cmd/inboxmessage.go index 078025a..16e482d 100644 --- a/pkg/cmd/inboxmessage.go +++ b/pkg/cmd/inboxmessage.go @@ -87,6 +87,11 @@ var inboxesMessagesList = cli.Command{ Usage: "Include trash in results.", QueryPath: "include_trash", }, + &requestflag.Flag[*bool]{ + Name: "include-unauthenticated", + Usage: "Include unauthenticated in results.", + QueryPath: "include_unauthenticated", + }, &requestflag.Flag[any]{ Name: "label", Usage: "Labels to filter by.", diff --git a/pkg/cmd/inboxmessage_test.go b/pkg/cmd/inboxmessage_test.go index 2fbd4d9..d21c0e9 100644 --- a/pkg/cmd/inboxmessage_test.go +++ b/pkg/cmd/inboxmessage_test.go @@ -52,6 +52,7 @@ func TestInboxesMessagesList(t *testing.T) { "--include-blocked=true", "--include-spam=true", "--include-trash=true", + "--include-unauthenticated=true", "--label", "[string]", "--limit", "0", "--page-token", "page_token", diff --git a/pkg/cmd/inboxthread.go b/pkg/cmd/inboxthread.go index 9256ed0..201208b 100644 --- a/pkg/cmd/inboxthread.go +++ b/pkg/cmd/inboxthread.go @@ -55,6 +55,11 @@ var inboxesThreadsList = cli.Command{ Usage: "Include trash in results.", QueryPath: "include_trash", }, + &requestflag.Flag[*bool]{ + Name: "include-unauthenticated", + Usage: "Include unauthenticated in results.", + QueryPath: "include_unauthenticated", + }, &requestflag.Flag[any]{ Name: "label", Usage: "Labels to filter by.", diff --git a/pkg/cmd/inboxthread_test.go b/pkg/cmd/inboxthread_test.go index 73b0e25..71c86ab 100644 --- a/pkg/cmd/inboxthread_test.go +++ b/pkg/cmd/inboxthread_test.go @@ -22,6 +22,7 @@ func TestInboxesThreadsList(t *testing.T) { "--include-blocked=true", "--include-spam=true", "--include-trash=true", + "--include-unauthenticated=true", "--label", "[string]", "--limit", "0", "--page-token", "page_token", diff --git a/pkg/cmd/podthread.go b/pkg/cmd/podthread.go index cb3cbdf..084222e 100644 --- a/pkg/cmd/podthread.go +++ b/pkg/cmd/podthread.go @@ -55,6 +55,11 @@ var podsThreadsList = cli.Command{ Usage: "Include trash in results.", QueryPath: "include_trash", }, + &requestflag.Flag[*bool]{ + Name: "include-unauthenticated", + Usage: "Include unauthenticated in results.", + QueryPath: "include_unauthenticated", + }, &requestflag.Flag[any]{ Name: "label", Usage: "Labels to filter by.", diff --git a/pkg/cmd/podthread_test.go b/pkg/cmd/podthread_test.go index fe7bab7..f2c674a 100644 --- a/pkg/cmd/podthread_test.go +++ b/pkg/cmd/podthread_test.go @@ -22,6 +22,7 @@ func TestPodsThreadsList(t *testing.T) { "--include-blocked=true", "--include-spam=true", "--include-trash=true", + "--include-unauthenticated=true", "--label", "[string]", "--limit", "0", "--page-token", "page_token", diff --git a/pkg/cmd/thread.go b/pkg/cmd/thread.go index 031e1fe..b9a345d 100644 --- a/pkg/cmd/thread.go +++ b/pkg/cmd/thread.go @@ -49,6 +49,11 @@ var threadsList = cli.Command{ Usage: "Include trash in results.", QueryPath: "include_trash", }, + &requestflag.Flag[*bool]{ + Name: "include-unauthenticated", + Usage: "Include unauthenticated in results.", + QueryPath: "include_unauthenticated", + }, &requestflag.Flag[any]{ Name: "label", Usage: "Labels to filter by.", diff --git a/pkg/cmd/thread_test.go b/pkg/cmd/thread_test.go index 9835b56..b9d55f9 100644 --- a/pkg/cmd/thread_test.go +++ b/pkg/cmd/thread_test.go @@ -21,6 +21,7 @@ func TestThreadsList(t *testing.T) { "--include-blocked=true", "--include-spam=true", "--include-trash=true", + "--include-unauthenticated=true", "--label", "[string]", "--limit", "0", "--page-token", "page_token", From dbc4e3921846cff6f687cd96b4c46163f8785baf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 2 May 2026 02:56:22 +0000 Subject: [PATCH 22/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee5f017..45eb322 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.10.1 + github.com/agentmail-to/agentmail-go v0.11.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index ef57205..707e946 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.10.1 h1:gwFSKxKeNswKI4lvSU8ZYZlCCJ+lJxWGN0eOunxMgTM= -github.com/agentmail-to/agentmail-go v0.10.1/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.11.0 h1:I9o5dzEOhmMrq+jswcMU9K1/YtqemC3yDfQffby0Dhw= +github.com/agentmail-to/agentmail-go v0.11.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From d3bae3e70698a8869a12853ee029755a7654ff67 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 04:12:53 +0000 Subject: [PATCH 23/31] chore: redact api-key headers in debug logs --- internal/debugmiddleware/debug_middleware.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/debugmiddleware/debug_middleware.go b/internal/debugmiddleware/debug_middleware.go index f07b93b..647f1de 100644 --- a/internal/debugmiddleware/debug_middleware.go +++ b/internal/debugmiddleware/debug_middleware.go @@ -21,7 +21,12 @@ const redactedPlaceholder = "" // Headers known to contain sensitive information like an API key. Note that this exclude `Authorization`, // which is handled specially in `redactRequest` below. -var sensitiveHeaders = []string{} +var sensitiveHeaders = []string{ + "api-key", + "x-api-key", + "cookie", + "set-cookie", +} // RequestLogger is a middleware that logs HTTP requests and responses. type RequestLogger struct { From 95968dd8267ca302ca54e626fff6e71a58542cbf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 9 May 2026 03:32:34 +0000 Subject: [PATCH 24/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 45eb322..9a297a2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.11.0 + github.com/agentmail-to/agentmail-go v0.11.2 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 707e946..e70cb06 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.11.0 h1:I9o5dzEOhmMrq+jswcMU9K1/YtqemC3yDfQffby0Dhw= -github.com/agentmail-to/agentmail-go v0.11.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.11.2 h1:6ItKD4/ocN8tXswMe/hBx9PPqFDwUBo6T1Nox+tnMbI= +github.com/agentmail-to/agentmail-go v0.11.2/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From 8b4bc7f86ba1f1e722d5300b54996b946b4ee544 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 11 May 2026 01:30:32 +0000 Subject: [PATCH 25/31] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6d38055..7f7c48b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-a891f5285b07e5b0a91547cce9635fcb7da35952d178427343230e2eb17fc5a1.yml -openapi_spec_hash: 5c6ec5f8ecc60c5c22be81a5e6fbb895 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-f411e2484cc5c5ebbcf2f86e519b0d3afe7668fca619a325d03fb1905b0eb7ad.yml +openapi_spec_hash: 58ca0dfaab8e0ea58772aab34c6756bc config_hash: 8ab5eb1bfc282411f0283d386a319f23 From ade97ba09762aaa0c9fd868b1137a107ada935eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 02:49:04 +0000 Subject: [PATCH 26/31] ci: pin GitHub Actions to commit SHAs Pin all GitHub Actions referenced in generated workflows (both first-party `actions/*` and third-party) to immutable commit SHAs. Updating pinned actions is now a deliberate codegen-side bump rather than implicit on every workflow run. --- .github/actions/setup-go/action.yml | 4 ++-- .github/workflows/ci.yml | 10 +++++----- .github/workflows/publish-release.yml | 6 +++--- .github/workflows/release-doctor.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 6c4c259..eb7b832 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -7,7 +7,7 @@ inputs: runs: using: composite steps: - - uses: stainless-api/retrieve-github-access-token@v1 + - uses: stainless-api/retrieve-github-access-token@1f03f929b746c5b03dcdafa2bebbb18ca5672e1a # v1.0.0 if: github.repository == 'stainless-sdks/agentmail-cli' id: get_token with: @@ -20,7 +20,7 @@ runs: run: git config --global url."https://x-access-token:${{ steps.get_token.outputs.github_access_token }}@github.com/stainless-sdks/agentmail-go".insteadOf "https://github.com/stainless-sdks/agentmail-go" - name: Setup go - uses: actions/setup-go@v5 + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 with: go-version-file: ./go.mod diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 310fdcc..1556dd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: ./.github/actions/setup-go with: @@ -51,7 +51,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/agentmail-cli' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: ./.github/actions/setup-go with: @@ -66,7 +66,7 @@ jobs: run: ./scripts/bootstrap - name: Run goreleaser - uses: goreleaser/goreleaser-action@v6.1.0 + uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: version: latest args: release --snapshot --clean --skip=publish @@ -78,7 +78,7 @@ jobs: github.repository == 'stainless-sdks/agentmail-cli' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -98,7 +98,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/agentmail-cli' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: ./.github/actions/setup-go with: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 81520dc..0af93f4 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -16,15 +16,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 with: go-version-file: "go.mod" - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6.1.0 + uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: version: latest args: release --clean diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 92e05a8..e672552 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'agentmail-to/agentmail-cli' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | From 8daa4e303af3d3e8b2543e1c294dbbac08dbbb2a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 02:22:22 +0000 Subject: [PATCH 27/31] feat(api): api update --- .stats.yml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/cmd/agent.go | 10 ++++++++++ pkg/cmd/agent_test.go | 6 +++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7f7c48b..0d8496d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-f411e2484cc5c5ebbcf2f86e519b0d3afe7668fca619a325d03fb1905b0eb7ad.yml -openapi_spec_hash: 58ca0dfaab8e0ea58772aab34c6756bc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-ebbe8447cb68fb0334ac1d5e36120fbb5a1a9c2d09525ad0e99bbe81f84da1b8.yml +openapi_spec_hash: fc6edf9323ca0043629a65a9221bd5f3 config_hash: 8ab5eb1bfc282411f0283d386a319f23 diff --git a/go.mod b/go.mod index 9a297a2..65a3e14 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.11.2 + github.com/agentmail-to/agentmail-go v0.11.3 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index e70cb06..9a98ef8 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.11.2 h1:6ItKD4/ocN8tXswMe/hBx9PPqFDwUBo6T1Nox+tnMbI= -github.com/agentmail-to/agentmail-go v0.11.2/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.11.3 h1:m0uSD3MvEx8Vbz4CpJolG5CS4IK3xGSICrHOaBpaIJI= +github.com/agentmail-to/agentmail-go v0.11.3/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= diff --git a/pkg/cmd/agent.go b/pkg/cmd/agent.go index 40d9d01..bc75542 100644 --- a/pkg/cmd/agent.go +++ b/pkg/cmd/agent.go @@ -31,6 +31,16 @@ var agentSignUp = cli.Command{ Required: true, BodyPath: "username", }, + &requestflag.Flag[*string]{ + Name: "referrer", + Usage: "The channel that drove this sign-up — where the agent or its developer discovered AgentMail\n(e.g. `agent.email`, a partner URL, a campaign tag). Answers \"where did this sign-up come from\".\nMax 2048 characters.", + BodyPath: "referrer", + }, + &requestflag.Flag[*string]{ + Name: "source", + Usage: "The SDK, framework, or platform issuing this sign-up (e.g. `agentmail-python`, `agentmail-cli`, `agentmail-mcp`).\nIdentifies the caller — answers \"who is signing up\".\nMax 2048 characters.", + BodyPath: "source", + }, }, Action: handleAgentSignUp, HideHelpCommand: true, diff --git a/pkg/cmd/agent_test.go b/pkg/cmd/agent_test.go index ecea87d..8f744a0 100644 --- a/pkg/cmd/agent_test.go +++ b/pkg/cmd/agent_test.go @@ -17,6 +17,8 @@ func TestAgentSignUp(t *testing.T) { "agent", "sign-up", "--human-email", "human_email", "--username", "username", + "--referrer", "referrer", + "--source", "source", ) }) @@ -24,7 +26,9 @@ func TestAgentSignUp(t *testing.T) { // Test piping YAML data over stdin pipeData := []byte("" + "human_email: human_email\n" + - "username: username\n") + "username: username\n" + + "referrer: referrer\n" + + "source: source\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", From aa9681503fff5488e7b02db6e210c055f6699f19 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 03:36:45 +0000 Subject: [PATCH 28/31] chore(internal): codegen related update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 65a3e14..8ed173c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.11.3 + github.com/agentmail-to/agentmail-go v0.12.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 9a98ef8..d470021 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.11.3 h1:m0uSD3MvEx8Vbz4CpJolG5CS4IK3xGSICrHOaBpaIJI= -github.com/agentmail-to/agentmail-go v0.11.3/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.12.0 h1:l8xM0VVsh9v0SH5xWVm3ktSkJuF2AsrRvPhTsFcNsrM= +github.com/agentmail-to/agentmail-go v0.12.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From 2a05aba658ca45f0a782575b47c8f159ca67a186 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 04:05:44 +0000 Subject: [PATCH 29/31] feat(api): api update --- .stats.yml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/cmd/webhook.go | 9 +++++++-- pkg/cmd/webhook_test.go | 3 +++ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0d8496d..e3c221d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-ebbe8447cb68fb0334ac1d5e36120fbb5a1a9c2d09525ad0e99bbe81f84da1b8.yml -openapi_spec_hash: fc6edf9323ca0043629a65a9221bd5f3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/agentmail/agentmail-ec4e26c46715d10a0de953666e890ab67f97e61f7355971ed728942f957100f8.yml +openapi_spec_hash: 74a582c32cd3a4f6e2afb1e84eccbb21 config_hash: 8ab5eb1bfc282411f0283d386a319f23 diff --git a/go.mod b/go.mod index 8ed173c..2eb96d4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.12.0 + github.com/agentmail-to/agentmail-go v0.13.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index d470021..129f258 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.12.0 h1:l8xM0VVsh9v0SH5xWVm3ktSkJuF2AsrRvPhTsFcNsrM= -github.com/agentmail-to/agentmail-go v0.12.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.13.0 h1:sYxi7ZtETy9xUTp8JdHh8i1GEAy66cYPHhsMa+uneD0= +github.com/agentmail-to/agentmail-go v0.13.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= diff --git a/pkg/cmd/webhook.go b/pkg/cmd/webhook.go index 0ea6a4f..0294e1d 100644 --- a/pkg/cmd/webhook.go +++ b/pkg/cmd/webhook.go @@ -21,7 +21,7 @@ var webhooksCreate = cli.Command{ Flags: []cli.Flag{ &requestflag.Flag[[]string]{ Name: "event-type", - Usage: "Event types for which to send events.", + Usage: "Full list of event types this webhook should receive. At least one type is required. Send every type you\nwant in this array (not incremental). See [Webhooks overview](https://docs.agentmail.to/webhooks-overview)\nfor spam, blocked, and unauthenticated events and required permissions.", Required: true, BodyPath: "event_types", }, @@ -53,7 +53,7 @@ var webhooksCreate = cli.Command{ var webhooksUpdate = cli.Command{ Name: "update", - Usage: "**CLI:**", + Usage: "Update inbox or pod subscriptions, or replace the webhook's `event_types` in\nfull when you pass a non-empty `event_types` array (see request field docs).\nInbox and pod changes use add/remove lists.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -72,6 +72,11 @@ var webhooksUpdate = cli.Command{ Usage: "Pod IDs to subscribe to the webhook.", BodyPath: "add_pod_ids", }, + &requestflag.Flag[any]{ + Name: "event-type", + Usage: "When you send a non-empty list, it replaces the webhook's subscribed event types in full (the same\n\"set the list\" behavior as create). It is not a merge or diff: include every event type you want after\nthe update. Sending a one-element array means the webhook will only receive that one type afterward.\nOmit this field or send an empty array to leave event types unchanged. Clearing all types with an empty\nlist is not supported. Subscribing to `message.received.spam`, `message.received.blocked`, or\n`message.received.unauthenticated` requires the matching label permission on the API key.", + BodyPath: "event_types", + }, &requestflag.Flag[any]{ Name: "remove-inbox-id", Usage: "Inbox IDs to unsubscribe from the webhook.", diff --git a/pkg/cmd/webhook_test.go b/pkg/cmd/webhook_test.go index 03d11cb..c5c929b 100644 --- a/pkg/cmd/webhook_test.go +++ b/pkg/cmd/webhook_test.go @@ -52,6 +52,7 @@ func TestWebhooksUpdate(t *testing.T) { "--webhook-id", "webhook_id", "--add-inbox-id", "[string]", "--add-pod-id", "[string]", + "--event-type", "[message.received]", "--remove-inbox-id", "[string]", "--remove-pod-id", "[string]", ) @@ -64,6 +65,8 @@ func TestWebhooksUpdate(t *testing.T) { " - string\n" + "add_pod_ids:\n" + " - string\n" + + "event_types:\n" + + " - message.received\n" + "remove_inbox_ids:\n" + " - string\n" + "remove_pod_ids:\n" + From a842755950fd6fa4ccbf2c890025e2d22ab48f97 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 22:06:20 +0000 Subject: [PATCH 30/31] chore: update SDK settings --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2eb96d4..daf7971 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/agentmail-to/agentmail-cli go 1.25 require ( - github.com/agentmail-to/agentmail-go v0.13.0 + github.com/agentmail-to/agentmail-go v0.14.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index 129f258..d034339 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/agentmail-to/agentmail-go v0.13.0 h1:sYxi7ZtETy9xUTp8JdHh8i1GEAy66cYPHhsMa+uneD0= -github.com/agentmail-to/agentmail-go v0.13.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= +github.com/agentmail-to/agentmail-go v0.14.0 h1:oEZQResNnsqY7aZl2zoXoQdAHYltsROr51Z+gNEHhS8= +github.com/agentmail-to/agentmail-go v0.14.0/go.mod h1:3NrKbeXLQKRgb9gj2bmCoN9WXDTy9y9yacV070xpvDU= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= From caa57463c3f2ae70ee2d957b0b132114a6991f0e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 22:16:27 +0000 Subject: [PATCH 31/31] release: 0.7.12 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++ pkg/cmd/version.go | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index de6d4ca..2daf110 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.7.11" + ".": "0.7.12" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b640a72..faa61ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ # Changelog +## 0.7.12 (2026-05-14) + +Full Changelog: [v0.7.11...v0.7.12](https://github.com/agentmail-to/agentmail-cli/compare/v0.7.11...v0.7.12) + +### Features + +* **api:** api update ([2a05aba](https://github.com/agentmail-to/agentmail-cli/commit/2a05aba658ca45f0a782575b47c8f159ca67a186)) +* **api:** api update ([8daa4e3](https://github.com/agentmail-to/agentmail-cli/commit/8daa4e303af3d3e8b2543e1c294dbbac08dbbb2a)) +* **api:** api update ([42b296a](https://github.com/agentmail-to/agentmail-cli/commit/42b296accc273d1f43984b7a978500f5f4c890fd)) +* **cli:** add `--raw-output`/`-r` option to print raw (non-JSON) strings ([f9df419](https://github.com/agentmail-to/agentmail-cli/commit/f9df419dc3ba3b15a8a267db59207e81eea217f5)) +* **cli:** alias parameters in data with `x-stainless-cli-data-alias` ([ea26a8c](https://github.com/agentmail-to/agentmail-cli/commit/ea26a8c2a975386b3a00bf181d877e3eeb40c3f1)) +* **cli:** send filename and content type when reading input from files ([65a86ee](https://github.com/agentmail-to/agentmail-cli/commit/65a86ee9ddb38368eebc5a472380d9d85b4fb6c5)) +* support passing path and query params over stdin ([86c8aab](https://github.com/agentmail-to/agentmail-cli/commit/86c8aab82328e0362b0d699464f1a55a9421b4e7)) + + +### Bug Fixes + +* **cli:** correctly load zsh autocompletion ([1b982f7](https://github.com/agentmail-to/agentmail-cli/commit/1b982f78a9d150901b940791d7bc05fe1a396e49)) +* flags for nullable body scalar fields are strictly typed ([f105a97](https://github.com/agentmail-to/agentmail-cli/commit/f105a97104a8e6be911e6419733d9c7628577d84)) + + +### Chores + +* **ci:** support manually triggering release workflow ([0e60014](https://github.com/agentmail-to/agentmail-cli/commit/0e6001439c676f9b793176e39417f69ff94d01ac)) +* **cli:** fall back to JSON when using default "explore" with non-TTY ([fbfe2c1](https://github.com/agentmail-to/agentmail-cli/commit/fbfe2c1e0e56a779a885443c2d0d4743b512e242)) +* **cli:** switch long lists of positional args over to param structs ([d227554](https://github.com/agentmail-to/agentmail-cli/commit/d227554129ec4bddcf6ba84af9f08fe49247ea82)) +* **cli:** use `ShowJSONOpts` as argument to `formatJSON` instead of many positionals ([0e94446](https://github.com/agentmail-to/agentmail-cli/commit/0e944460e3f00ab8cb1040bb18e0380bb3574dbe)) +* **internal:** codegen related update ([aa96815](https://github.com/agentmail-to/agentmail-cli/commit/aa9681503fff5488e7b02db6e210c055f6699f19)) +* **internal:** codegen related update ([95968dd](https://github.com/agentmail-to/agentmail-cli/commit/95968dd8267ca302ca54e626fff6e71a58542cbf)) +* **internal:** codegen related update ([dbc4e39](https://github.com/agentmail-to/agentmail-cli/commit/dbc4e3921846cff6f687cd96b4c46163f8785baf)) +* **internal:** codegen related update ([5b36c53](https://github.com/agentmail-to/agentmail-cli/commit/5b36c5391637ffda46b95c9095acda6f6be532e9)) +* **internal:** codegen related update ([c7f1282](https://github.com/agentmail-to/agentmail-cli/commit/c7f1282aabb0958db3b8dd601bdca796e5dc0f57)) +* **internal:** codegen related update ([b25c8cb](https://github.com/agentmail-to/agentmail-cli/commit/b25c8cb53998ae20441273aa550a0b435b608bf3)) +* **internal:** more robust bootstrap script ([8b39e72](https://github.com/agentmail-to/agentmail-cli/commit/8b39e720cbe7e3c2c150bd7f2a563dd0feb298bf)) +* redact api-key headers in debug logs ([d3bae3e](https://github.com/agentmail-to/agentmail-cli/commit/d3bae3e70698a8869a12853ee029755a7654ff67)) +* update SDK settings ([a842755](https://github.com/agentmail-to/agentmail-cli/commit/a842755950fd6fa4ccbf2c890025e2d22ab48f97)) + ## 0.7.11 (2026-04-14) Full Changelog: [v0.7.10...v0.7.11](https://github.com/agentmail-to/agentmail-cli/compare/v0.7.10...v0.7.11) diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 1830802..d0a0ee8 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -2,4 +2,4 @@ package cmd -const Version = "0.7.11" // x-release-please-version +const Version = "0.7.12" // x-release-please-version