From 32f5a8d933df2c1ffcd5aea38414ae09896a0306 Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Tue, 23 Jun 2026 20:29:37 +0100 Subject: [PATCH] fix(cli): clarify edit --from help; test edit --from validation Co-Authored-By: Claude Opus 4.8 (1M context) --- internal/cli/admin.go | 2 +- internal/cli/admin_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/cli/admin.go b/internal/cli/admin.go index 81a42b5..dabfcb3 100644 --- a/internal/cli/admin.go +++ b/internal/cli/admin.go @@ -91,7 +91,7 @@ func runAccount(args []string, role store.Role, out, errOut io.Writer) int { smtpSec := fs.String("smtp-security", "", "tls|starttls") user := fs.String("username", "", "login username") pass := fs.String("password", "", "login password (blank keeps existing)") - from := fs.String("from", "", "send-as address (blank keeps existing)") + from := fs.String("from", "", "send-as address (empty reverts to username)") subj := fs.String("subject-regex", "", "inbound subject filter") if err := fs.Parse(rest); err != nil { return 2 diff --git a/internal/cli/admin_test.go b/internal/cli/admin_test.go index 1a2f7f9..c93e077 100644 --- a/internal/cli/admin_test.go +++ b/internal/cli/admin_test.go @@ -132,3 +132,17 @@ func TestAuditListCoreRenders(t *testing.T) { } } +func TestAccountEditFromValidationRejectsMailformed(t *testing.T) { + adminEnv(t) + // Seed an account so the failure is from --from validation, not a missing account. + run(t, "account", "add", "--name", "valacc", "--imap-host", "imap.x.com", "--username", "u@x.com") + // A malformed --from value must be rejected with exit code 2 before touching the account. + code, _, errStr := run(t, "account", "edit", "--name", "valacc", "--from", "not an address") + if code != 2 { + t.Fatalf("expected exit code 2 for malformed --from, got %d (stderr: %q)", code, errStr) + } + if errStr == "" { + t.Fatal("expected an error message on stderr for malformed --from, got none") + } +} +