Skip to content

feat(gmail): add signature support to send command#183

Open
salmonumbrella wants to merge 48 commits intosteipete:mainfrom
salmonumbrella:feat/gmail-send-signature
Open

feat(gmail): add signature support to send command#183
salmonumbrella wants to merge 48 commits intosteipete:mainfrom
salmonumbrella:feat/gmail-send-signature

Conversation

@salmonumbrella
Copy link
Contributor

@salmonumbrella salmonumbrella commented Feb 4, 2026

Closes #180

Summary

  • Add --signature, --signature-name, and --signature-file flags to gmail send for appending Gmail signatures to outgoing messages
  • Fetch signature from Gmail send-as settings (default or specific alias) or from a local file
  • Auto-detect signature file content type (plain text vs HTML) and convert appropriately for both body formats
  • Improved HTML-to-plain text conversion handling <p>, <div>, <tr>, <a> tags (not just <br>)
  • 1 MB file size limit on --signature-file for safety
  • Comprehensive test coverage: integration tests for all three signature modes, unit tests for all helper functions, table-driven edge case tests

Test plan

  • All existing tests pass (go test ./...)
  • golangci-lint reports 0 issues
  • New tests cover: plain text signature, HTML signature, signature-name alias path, file-not-found error, file-too-large error, HTML-to-plain conversion (15 cases), content type detection, plain-to-HTML conversion, append helpers, flag validation (8 combinations)

🤖 Generated with Claude Code

salmonumbrella and others added 30 commits February 2, 2026 20:09
The commit 5137fcb added --history-types flag but changed the default
behavior: when not specified, it now fetched ALL history types instead
of just messageAdded (the previous hardcoded behavior).

This fix ensures backward compatibility by defaulting to messageAdded
when --history-types is not provided.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When messageDeleted history type is requested, deleted messages cannot
be fetched from Gmail API (returns 404). Now collectHistoryMessageIDs
returns a struct with separate FetchIDs and DeletedIDs lists, and the
hook payload includes deletedMessageIds field for consumers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add canonical forms to history type alias map for robustness
- Add length assertion for FetchIDs in TestCollectHistoryMessageIDs
- Clarify documentation that default is messageAdded
- Add test for empty input edge case in parseHistoryTypes
- Extract duplicate state update logic into updateStateAfterHistory helper

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename inner `err` to `updateErr` to avoid shadowing the outer
variable, satisfying golangci-lint's govet shadow checker.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename inner `err` to `updateErr` in two additional store.Update()
calls to avoid shadowing outer variables, completing the fix from
commit 71714ae. Both locations now match the established pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace custom contains() helper with Go's built-in strings.Contains()
- Add TestProcess_ReadFromStdin to test stdin input via "-" path
- All 47 tests pass successfully

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add special character constant with 20+ unique characters
- Guarantee at least one special character in generated passwords
- Meet typical organizational password policies requiring uppercase, lowercase, digit, and special character
- Ensures passwords pass NIST and common security standards
…ting

Add --dry-run flag to batch.go and csv.go that shows which commands would be
executed without actually running them. This is important for bulk operations
to safely preview before execution.

- batch.go: Added DryRun field to BatchCmd, implements preview with
  "[dry-run] line N: cmd arg1 arg2 ..." format
- csv.go: Added DryRun field to CSVCmd, implements preview with
  "[dry-run] row N: cmd arg1 arg2 ..." format
- csv_test.go: Added TestBatchCmdDryRun and TestCSVCmdDryRun tests to verify
  dry-run mode prevents command execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace hardcoded cloudIdentityDefaultParent constant with a function that checks for the GOG_CUSTOMER_ID environment variable. If set, uses "customers/{value}" as the parent; otherwise falls back to "customers/my_customer". Update help text for --parent flags to document this new env var override.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, Clear() and Update() calls hardcoded "Sheet1" range regardless of the
actual first sheet name in the spreadsheet. This could cause failures when the
first sheet had a different name.

Changes:
- When creating new spreadsheets, explicitly set the first sheet title to "Data"
- When updating existing spreadsheets, fetch the first sheet name from metadata
- Use the actual sheet name (stored in sheetName variable) in Clear() and Update() calls

This ensures the code works with spreadsheets that have any first sheet name,
not just "Sheet1".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- cloudidentity.go: Add CEL expression example to --dynamic-query help
- csv.go: Add field substitution and regex pattern examples
- batch.go: Clarify batch file format in help text
Replace fmt.Fprintf(os.Stdout, ...) with u.Out().Printf(...) across all
command files for consistent output handling through the UI abstraction.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add vault tests: matters CRUD, exports, holds
- Add roles tests: get, update, delete, privileges
- Add admin groups tests: update, delete, settings, members sync
- Increases cmd package coverage from 63.1% to 65.5%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 45 new tests for resources buildings, calendars, and features commands:
- Buildings: list, get, create, update, delete (with JSON/text output variants)
- Calendars: list, get, create, update, delete (with JSON/text output variants)
- Features: list, create, delete (with JSON/text output variants)
- Input validation tests for empty IDs and missing required fields
- Pagination and filtering tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for AlertsGetCmd, AlertsDeleteCmd, AlertsUndeleteCmd,
AlertsFeedbackCreateCmd, AlertsFeedbackListCmd, AlertsSettingsUpdateCmd,
AliasesCreateCmd, and AliasesDeleteCmd. Tests cover plain text output,
JSON output mode, validation errors, and confirmation requirements.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for DomainsGetCmd, DomainsCreateCmd, DomainsDeleteCmd,
DomainsAliasesListCmd, DomainsAliasesCreateCmd, and DomainsAliasesDeleteCmd.
Tests cover JSON and plain text output modes, error handling, missing
account validation, and confirmation requirements for destructive operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for contacts delegates, domain, import, export, and dedup commands:
- ContactsDelegatesAddCmd: add delegate functionality with JSON output
- ContactsDelegatesRemoveCmd: remove delegate functionality with JSON output
- ContactsDelegatesListCmd: JSON output and empty results handling
- ContactsDomainCreateCmd: create contact with JSON output and validation
- ContactsDomainDeleteCmd: delete by resource name/email with JSON output
- ContactsDomainListCmd: JSON output and pagination
- ContactsImportCmd: CSV parsing, JSON output, and error handling
- ContactsExportCmd: CSV export to file/stdout with JSON output
- ContactsDedupCmd: duplicate detection and dry-run mode

Also includes unit tests for CSV helper functions:
- normalizeCSVHeader, parseCSVRow, csvPerson
- openCSVReader, openCSVWriter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 36 new tests for printers and forms commands:

Printers (18 tests):
- PrintersListCmd: list, JSON output, empty results, pagination
- PrintersGetCmd: get, JSON output, empty ID validation
- PrintersCreateCmd: create, JSON output, missing name/URI validation
- PrintersUpdateCmd: update, empty ID and no-updates validation
- PrintersDeleteCmd: delete, empty ID validation, confirmation check
- Helper functions: printerResourceName, printerParent

Forms (18 tests):
- FormsListCmd: list, JSON output, empty results, pagination, user filter
- FormsGetCmd: get, JSON output, empty ID validation, no-title handling
- FormsCreateCmd: create, JSON output, missing/whitespace title validation
- FormsResponsesCmd: list responses, JSON output, empty results, empty form ID, pagination

All tests use mock HTTP servers to verify API interactions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add tests for CAA (Context-Aware Access) levels commands
- Add tests for Cloud Identity management commands
- Add tests for license management commands
- Add tests for schema management commands
- Add tests for data transfer commands
- Fix RootFlags.Yes -> RootFlags.Force in caa_test.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
salmonumbrella and others added 18 commits February 3, 2026 13:28
- Add comprehensive tests for config commands
- Fix TestTransferApplicationsCmd_JSON: use string type for ID since JSON
  output serializes int64 as string

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ports, reseller, serviceaccounts

Add extensive test coverage for previously uncovered commands:
- labels: list, get, create, delete with JSON/text output
- orgunits: create, delete, get, update, list
- projects: list, get with JSON/text output
- reports: activities, users, customer, drive, tokens
- reseller: customers list/get, subscriptions list/get
- serviceaccounts: list, create, delete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for calendar edit functions and event day parsing:
- applyCreateEventType with various event types and transparency settings
- parseEventTime and parseEventDate with valid and invalid inputs
- edge cases for all-day events and timezone handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add extensive test coverage for authentication and chat commands:
- Auth tests for login, status, logout, info, and switch flows
- Chat tests for spaces, messages, threads operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add extensive test coverage for Google Classroom commands:
- Courses (list, get, create, update, join, leave, url)
- Coursework (list, get, create, assignees)
- Guardians and guardian invites
- Invitations (list, get, create, accept, delete)
- Announcements (list, get, create, delete)
- Materials (list, get, create, update, delete)
- Roster, students, teachers, profile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add shared EscapeDriveQueryValue to googleapi package that escapes
backslashes and single quotes, preventing query injection when
user-provided values contain those characters. Applied at all five
interpolation sites and deduplicated existing local escape helpers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Inline Drive query escape wrappers to use shared EscapeDriveQueryValue directly
- Add comprehensive unit tests for EscapeDriveQueryValue
- Fix CloudIdentity groups get to use UI layer instead of direct os.Stdout
- Remove duplicate splitCSVFields, use splitCSV from split_helpers.go
- Make adminCustomerID configurable via GOG_CUSTOMER_ID env var
- Add t.Parallel() safety comment to testutil_test.go
- Move cloudchannel stub from testutil_test.go to channel_test.go
- Fix batch.go channel close pattern with goroutine
- Document readValueOrFile file detection heuristic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address 124 lint findings across err113, goconst, govet shadow,
gosec, unparam, wsl, staticcheck, thelper, nilnil, predeclared,
ineffassign, and errorlint categories.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add --signature, --signature-name, and --signature-file flags to append
Gmail signatures to outgoing messages. Supports fetching from Gmail
send-as settings or from a local file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Handle p/div/tr closing tags as line breaks, convert anchor tags to
"text (URL)" format, collapse excessive newlines, and trim trailing
whitespace. Adds table-driven unit tests covering all tag variants.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmail send: Add --signature flag to append Gmail signature

1 participant