feat: add zemo dump to print all memos#8
Merged
Merged
Conversation
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
Add a
zemo dumpsubcommand that prints scratch and every topic to stdout under=== <name> ===section headers, ordered as scratch first then topics alphabetically. Read-only — no git operations. Completes the search/discovery primitive set (ls/cat/dump) so terminal-side search such as WezTerm QuickSearch can grep across all memos in a single pass.This PR also bumps the version to 0.2.0, intended to be tagged immediately after merge.
Related issue
Closes #5
Changes
Command.dumpvariant incli.zig; routed fromparseArgs(rejects extra args) and dispatched inrun.doDump(env → memo dir) anddumpMemos(path-based, testable) helpers.=== scratch ===for scratch,=== <topic> ===for each topic. Blank lines before/after the header for readability; previous-section trailing-newline tracking avoids accidental double blanks between sections.<memo>/scratch.txt(printed first if present) followed by alphabetically sorted<memo>/topics/*.md. Subdirectories and non-.mdfiles undertopics/are excluded. Missing scratch / missingtopics/are skipped silently (exit 0 with no output if both are missing).Io.Reader.streamRemaining(4 KiB read buffer) — bounded memory regardless of file size.listTopicswas split — directory iteration / filter / sort moved into a sharedcollectTopicNameshelper that bothlistTopicsanddumpMemoscall.errdefer(notdefer) is used in the helper so the returned list is not freed on success.zemo dumpto Features and Usage sections.zemo dumpline.VERSIONconstant incli.zigupdated from0.1.0to0.2.0. After merge, tagv0.2.0to trigger the release workflow (binaries + auto-generated release notes covering feat: addzemo lsto list topics #6ls, feat: addzemo catto print memo to stdout #7cat, feat: addzemo dumpto print all memos #8dump, plus the relative-ZEMO_DIRfix from feat: addzemo lsto list topics #6).Testing
zig build testpasses locallyzig build run -- dumpagainst~/memo,zig build run -- --versionreportszemo 0.2.0)zig build -Dtarget=x86_64-windows/-Dtarget=x86_64-macosNew tests added:
parseArgs: dump subcommand— parser-leveldumpMemos: scratch only— only scratch presentdumpMemos: topics only sorted and filtered— alphabetical sort,.mdfilter, subdirectory exclusiondumpMemos: scratch and topics— full combined output, including blank-line spacing across sections with/without trailing newlinesdumpMemos: neither scratch nor topics prints nothing— empty memo casedoDump: uses ZEMO_DIR override— end-to-end through env-map resolutionNotes for reviewers
writeSectionHeader(previous_ended_with_newline+wrote_anyflags) is what enables the spec'd=== a ===\n\n<a>\n\n=== b ===\n\n<b>shape regardless of whether each file ends with a trailing newline. Tests cover both shapes.collectTopicNameswas a deliberate scope addition to avoid duplicating the iterate-filter-sort logic betweenlistTopicsanddumpMemos. The change tolistTopicsis mechanical (delegates to the helper) and remains covered by its existing test.writeTestFile/tmpDirPathare new — small wrappers used by the fourdumpMemostests to keep each test focused on the assertions rather than tmp-dir bookkeeping.git checkout main && git pull && git tag v0.2.0 && git push origin v0.2.0.