Skip to content

feat: support color flags in flag/unflag commands#49

Merged
cboone merged 6 commits intomainfrom
feature/support-color-flags-in-flag-unflag-commands
Feb 18, 2026
Merged

feat: support color flags in flag/unflag commands#49
cboone merged 6 commits intomainfrom
feature/support-color-flags-in-flag-unflag-commands

Conversation

@cboone
Copy link
Copy Markdown
Owner

@cboone cboone commented Feb 17, 2026

Summary

  • Add --color / -c flag to the flag command, accepting one of 7 color names (red, orange, yellow, green, blue, purple, gray) to set IETF $MailFlagBit keywords alongside $flagged
  • Add --color / -c boolean flag to the unflag command to clear only color bits while keeping the email flagged
  • Update plain unflag to also clear all color bits per the IETF spec recommendation
  • New FlagColor type in internal/client/color.go with 3-bit encoding, parsing, and JMAP patch generation

Test plan

  • Unit tests for ParseFlagColor (valid names, case-insensitive, invalid input)
  • Unit tests for FlagColor.Patch() verifying correct bit patterns for all 7 colors
  • Unit tests for SetFlaggedWithColor, SetUnflagged (now clears color bits), and ClearFlagColor patch structure
  • CLI snapshot tests for flag --color orange, flag -c blue, flag --color magenta (invalid), unflag --color
  • Help output snapshot tests updated for both commands
  • Docs drift test coverage extended to flag and unflag

Closes #33

Add --color / -c flag to the flag and unflag commands, supporting
Apple Mail and Fastmail color flags via the IETF $MailFlagBit keywords.

Valid colors: red, orange, yellow, green, blue, purple, gray.

The flag command sets $flagged plus the appropriate $MailFlagBit0/1/2
keywords. The unflag command now clears all color bits alongside
$flagged per the IETF spec recommendation. With --color on unflag,
only the color bits are removed while keeping the email flagged.

Closes #33
Copilot AI review requested due to automatic review settings February 17, 2026 19:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for colored flags in the flag and unflag commands, implementing the IETF MailFlagBit specification for flag colors. The implementation allows users to set one of seven flag colors (red, orange, yellow, green, blue, purple, gray) when flagging emails, and provides options to selectively clear color bits while maintaining flag state.

Changes:

  • Adds FlagColor type with 3-bit encoding for seven IETF-standard flag colors
  • Extends flag command with --color string flag to set colored flags
  • Extends unflag command with --color boolean flag to clear only color bits
  • Updates plain unflag to also clear all color bits per IETF spec recommendation

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/client/color.go New file implementing FlagColor type with parsing, validation, and JMAP patch generation for 3-bit color encoding
internal/client/color_test.go Comprehensive unit tests for color parsing, bit encoding, and all three client methods (SetFlaggedWithColor, SetUnflagged, ClearFlagColor)
internal/client/email.go Adds SetFlaggedWithColor and ClearFlagColor methods; updates SetUnflagged to clear color bits alongside $flagged
internal/client/email_test.go Updates TestUnflagPatchStructure to verify color bits are cleared when unflagging
cmd/flag.go Adds --color string flag with validation and integration to SetFlaggedWithColor
cmd/unflag.go Adds --color boolean flag to conditionally call ClearFlagColor instead of SetUnflagged
cmd/docs_drift_test.go Extends drift detection tests to cover flag and unflag commands
docs/CLI-REFERENCE.md Documents new --color flags for both commands with usage examples and IETF spec references
tests/help.md Updates help output snapshots to include --color flag in both commands
tests/flags.md Adds CLI snapshot tests for valid/invalid color usage and flag parsing
docs/plans/done/2026-02-17-support-color-flags-in-flag-unflag-commands.md Planning document capturing design decisions and IETF spec alignment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/flags.md
Comment thread internal/client/color.go
Comment thread cmd/flag.go Outdated
Rename `c` to `parsedColor` in the color parsing block to avoid
shadowing with the client variable `c` declared later in the same
function.

Also update Copilot instructions to document intentional patterns:
- ValidColorNames hardcoded rainbow ordering
- Scrut edge-case arguments for boolean flag testing
…-flags-in-flag-unflag-commands

* origin/main:
  fix: stop global flags section at next heading or rule
  test: add unit tests for remaining SearchEmails filter options
  test: derive drift coverage commands from root
  test: include session in drift-prevention coverage
  test: extend CLI drift-prevention tests to all commands

# Conflicts:
#	cmd/docs_drift_test.go
Copilot AI review requested due to automatic review settings February 18, 2026 00:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cboone cboone merged commit 4021025 into main Feb 18, 2026
1 check passed
@cboone cboone deleted the feature/support-color-flags-in-flag-unflag-commands branch February 18, 2026 00:44
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.

Support color flags in flag/unflag commands

2 participants