feat: add ids-only output support - #121
Merged
Merged
Conversation
doistbot
reviewed
Aug 27, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR adds a shared ids-only output mode to cli-core: a canonical resolveOutputMode helper, formatIds/outputIds emitters for string and numeric IDs, global --ids-only parsing with spinner gating, silent empty-state handling, and rejection of conflicting --json/--ndjson/--ids-only combinations — all well-tested and README-documented. Few things worth tightening:
printEmptyre-implements the flag→mode mapping inline instead of routing throughresolveOutputMode, leaving two sources of truth; funneling through the resolver also makes it throw on conflicting flags rather than silently preferring--json, matching the contract this PR introduces.- Minor type nit:
idsOnlyis declared optional on the parsedGlobalArgstype even though the parser always initializes it tofalse.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (3)
src/global-args.ts:20:
idsOnlyis declared viaPick<ListViewOptions, 'idsOnly'>(optional), butparseGlobalArgsalways returnsidsOnly: false. This is inconsistent withjson/ndjson, which areRequiredbecause they too are always populated. Consumers readingargs.idsOnlyend up withboolean | undefinedand need to handleundefinedeven though it never occurs. FoldidsOnlyinto theRequired<Pick<...>>for consistency:Required<Pick<ListViewOptions, 'json' | 'ndjson' | 'idsOnly'>>.src/commands/errors.ts:7:
CONFLICTING_OPTIONSis now listed underCommandErrorCode, whose doc comment says these are "codes thrown by@doist/cli-core/commands" — but the only throw site isresolveOutputModein the rootsrc/options.ts, not the commands subpath. Either amend the comment to note this code originates from the rootoptionsmodule, or move it to a root-level error-code union so the comment stays accurate.src/options.test.ts:49: The conflicts are asserted via
toThrow(message), matching the human-readable string.resolveOutputModethrows aCliErrorwith the stable'CONFLICTING_OPTIONS'code, so the tests should assert on that code instead, e.g.expect(() => resolveOutputMode(options)).toThrowError(expect.objectContaining({ code: 'CONFLICTING_OPTIONS' })). Coupling the test to the message makes any future wording change break it for the wrong reason.
Collaborator
Author
|
Addressed the review feedback in
The updated core build also passes the full Todoist CLI suite through a local package link. |
scottlovegrove
approved these changes
Aug 27, 2026
gnapse
force-pushed
the
ernesto/add-ids-only-output
branch
from
August 27, 2026 15:20
fa464d9 to
f956eb4
Compare
doist-release-bot Bot
added a commit
that referenced
this pull request
Aug 27, 2026
## [1.4.0](v1.3.0...v1.4.0) (2026-08-27) ### Features * add ids-only output support ([#121](#121)) ([43eaf80](43eaf80))
Contributor
|
🎉 This PR is included in version 1.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Doist CLIs need a consistent way to return stable entity IDs for scripts and agents without requiring each consumer to reimplement output-mode validation, empty-state behavior, and machine-output detection.
Summary
ListViewOptionsand a canonicalresolveOutputModehelperformatIdsandoutputIdsfor string and numeric IDs--ids-onlyas a global machine-output signal and disable spinners for it--json,--ndjson, and--ids-onlyExample
After release, Todoist CLI can replace its local helpers with these exports, and other CLIs can add the flag only to list commands with stable, unambiguous IDs.