Repository navigation
refactor(cli): strict parseArgs, unified --json contract, mailbox/body/date fixes, and updated docs - #21
Merged
Conversation
…y/date fixes, and updated docs
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.
Summary
parseArgs& safe global flag handling (src/cli.ts):args.includes("-h")/args.includes("--help")and globalconsumeJsonFlagscanning so flags inside option values (e.g.,--subject "foo --json",--body=-h, or--body "-h") never hijack help or JSON mode.--version/-v(reading version frompackage.json, with--jsonsupport).usage(1)) tostderrwhile keeping explicit--help/-honstdout.accounts,thread,drafts list|get|delete|send, andurlto strictparseArgs, rejecting unknown options like--boguscleanly.parseComposeArgsfordrafts createandsend: rejects passing both--bodyand--body-file, and names the exact missing required option (--to,--subject,--bodyor--body-file).search --maxas a positive integer via sharedparsePositiveIntOption.--jsoncontract & honest exit codes (src/cli.ts,src/json-format.ts):--jsonoutput across all remaining commands (accounts list|add|remove|credentials,labels <threadIds>,drafts get --download,drafts create,drafts delete,drafts send,send) while preserving existing JSON shapes onsearch,thread,labels list,drafts list,drafts get,drafts audit, andurl.labels <threadIds>now exits1when neither--addnor--removeis provided or when any thread modification fails (stderr in text mode; structuredresults/errorsin--jsonmode).accounts remove <email>now exits1when the account is not found..filter((id) => id !== "--json")inhandleUrl.src/cli.ts,src/json-format.ts):searchuses the latest message in each thread for sender/date, unionslabelIdsacross all messages in the thread, guards malformedDateheaders againstRangeError, and sanitizes\r/\n/\tin TSV columns.threadprintsGmail-Message-ID:separately from RFC 822Message-ID:and includesCc:when present; deduplicatedgetHeaderclosures into one shared helper.decodeBodyskips named attachments and non-text/*parts so inline binary attachments are never dumped as message text.formatSizeclamps unit indexing so >= 1 TB never formats asundefined.parseMailboxListrespects quoted display-name commas (e.g."McLemore, Will" <will@mclemoreauction.com>, jane@example.com).README.md,CHANGELOG.md,test/cli-ergonomics.test.js):--help,README.md, andCHANGELOG.md(through PRs fix(drafts): preserve Gmail thread when --reply-to receives a threadId #14–fix(security): delete dead code and harden MIME, attachment paths, OAuth, and token storage #19 + this PR).test/cli-ergonomics.test.jscovering all fixes above.Verification
npm ci --no-audit --no-fund— passednpm run lint(biome check src/) — passed (7 files, 0 errors)npm run typecheck(tsc --noEmit) — passednpm run build— passednpm test— 50/50 tests passing