From 41272d5b60ba1052aed645d19cd26d99d2f5b470 Mon Sep 17 00:00:00 2001 From: Ronny Rentner Date: Fri, 7 Aug 2026 13:29:34 +0200 Subject: [PATCH 1/2] feat(gmail): env-configure --auto-from-addressed-alias via GOG_GMAIL_AUTO_FROM_ADDRESSED_ALIAS --- internal/cmd/gmail_drafts.go | 4 ++-- internal/cmd/gmail_reply_commands.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cmd/gmail_drafts.go b/internal/cmd/gmail_drafts.go index d85159c9b..07e7529bc 100644 --- a/internal/cmd/gmail_drafts.go +++ b/internal/cmd/gmail_drafts.go @@ -267,7 +267,7 @@ type GmailDraftsCreateCmd struct { Quote bool `name:"quote" help:"Include quoted original message in reply (requires --reply-to-message-id or --thread-id)"` Attach []string `name:"attach" help:"Attachment file path (repeatable)"` From string `name:"from" help:"Send from this email address (must be a verified send-as alias)"` - AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message"` + AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message" env:"GOG_GMAIL_AUTO_FROM_ADDRESSED_ALIAS"` } type draftComposeInput struct { @@ -777,7 +777,7 @@ type GmailDraftsUpdateCmd struct { //nolint:lll // flag help text ClearReplyContext bool `name:"clear-reply-context" help:"Strip In-Reply-To/References from the draft, making it a standalone message. By default an update preserves the draft's existing reply headers."` From string `name:"from" help:"Send from this email address (must be a verified send-as alias)"` - AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message"` + AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message" env:"GOG_GMAIL_AUTO_FROM_ADDRESSED_ALIAS"` } func (c *GmailDraftsUpdateCmd) Run(ctx context.Context, flags *RootFlags) error { diff --git a/internal/cmd/gmail_reply_commands.go b/internal/cmd/gmail_reply_commands.go index 826b6ad47..3190b6b85 100644 --- a/internal/cmd/gmail_reply_commands.go +++ b/internal/cmd/gmail_reply_commands.go @@ -33,7 +33,7 @@ type GmailReplyOptions struct { NoQuote bool `name:"no-quote" help:"Do not include the original message below the reply"` Attach []string `name:"attach" sep:"none" help:"Attachment file path (repeatable)"` From string `name:"from" help:"Send from this email address (must be a verified send-as alias)"` - AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message"` + AutoFromAddressedAlias bool `name:"auto-from-addressed-alias" help:"When --from is omitted, reply from the verified send-as alias addressed by the original message" env:"GOG_GMAIL_AUTO_FROM_ADDRESSED_ALIAS"` Signature bool `name:"signature" help:"Append the Gmail signature from the active send-as address"` SignatureFrom string `name:"signature-from" help:"Append the Gmail signature from this send-as email address"` SignatureFile string `name:"signature-file" help:"Append a local signature file (plain text or HTML)"` From b2068d8cd2baf361c6179968061fda120e6c0971 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 8 Aug 2026 20:38:18 -0700 Subject: [PATCH 2/2] test(gmail): cover addressed-alias env default --- internal/cmd/gmail_auto_from_env_test.go | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/cmd/gmail_auto_from_env_test.go diff --git a/internal/cmd/gmail_auto_from_env_test.go b/internal/cmd/gmail_auto_from_env_test.go new file mode 100644 index 000000000..e890b1f62 --- /dev/null +++ b/internal/cmd/gmail_auto_from_env_test.go @@ -0,0 +1,41 @@ +package cmd + +import ( + "encoding/json" + "testing" +) + +func TestGmailAutoFromAddressedAliasEnvDefaults(t *testing.T) { + t.Setenv("GOG_GMAIL_AUTO_FROM_ADDRESSED_ALIAS", "1") + + tests := []struct { + name string + args []string + }{ + {name: "reply", args: []string{"gmail", "reply", "m1", "--body", "hello"}}, + {name: "reply all", args: []string{"gmail", "reply-all", "m1", "--body", "hello"}}, + {name: "draft create", args: []string{"gmail", "drafts", "create", "--to", "you@example.com", "--subject", "subject", "--body", "hello"}}, + {name: "draft update", args: []string{"gmail", "drafts", "update", "d1", "--subject", "subject", "--body", "hello"}}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + args := append([]string{"--json", "--dry-run"}, tc.args...) + result := executeWithTestRuntime(t, args, nil) + if result.err != nil { + t.Fatalf("Execute: %v\nstderr=%q", result.err, result.stderr) + } + var output struct { + Request struct { + AutoFromAddressedAlias bool `json:"auto_from_addressed_alias"` + } `json:"request"` + } + if err := json.Unmarshal([]byte(result.stdout), &output); err != nil { + t.Fatalf("decode: %v\nout=%q", err, result.stdout) + } + if !output.Request.AutoFromAddressedAlias { + t.Fatalf("environment default was not applied: %s", result.stdout) + } + }) + } +}