feat: negative message IDs as reverse inbox indices#7
Merged
Conversation
- Add cmd/msgid.go with resolveMessageID() helper that resolves -1 to the most recent inbox message, -2 to the second most recent, etc. via GET /fmsg (ordered by ID desc) - Add injectDashDash() in root.go to auto-insert '--' before any -N argument so pflag doesn't treat negative numbers as shorthand flags - Update get, del, update, add-to, attach, get-data, get-attach, rm-attach, and draft-send commands to use resolveMessageID() - Add unit tests for resolveMessageID() and injectDashDash() - Document the feature in README.md Agent-Logs-Url: https://github.com/markmnl/fmsg-cli/sessions/629c298b-2dde-4aa7-9b9f-258b118bfb3a Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/markmnl/fmsg-cli/sessions/629c298b-2dde-4aa7-9b9f-258b118bfb3a Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for negative numbers in message ID commands
feat: negative message IDs as reverse inbox indices
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commands accepting
<message-id>required knowing the exact ID. Users now pass negative indices (-1,-2, …) to reference recent messages by position.How it works
-1→ most recent inbox message,-2→ second most recent, resolved viaGET /fmsg(ID desc) with offset-N - 1fmsg get -1,fmsg del -1,fmsg get-data -2, etc. all work naturallyChanges
cmd/msgid.go—resolveMessageID(client, arg): positive IDs pass through; negative values hitGET /fmsg?limit=1&offset=<N-1>to resolve the actual IDcmd/root.go—injectDashDash()prepended toExecute(): scansos.Argsand inserts--before the first-\d+argument so pflag doesn't swallow it as a shorthand flag — users typefmsg get -1with no special syntax requiredget,del,update,add-to,attach,get-data,get-attach,rm-attach,draft send) updated to callresolveMessageIDcmd/msgid_test.go— unit tests for resolution logic andinjectDashDash(positive, -1/-2/-3, out-of-range, zero, invalid, flags-before-index)README.md— documents the feature with index table and examples