feat: add zemo cat to print memo to stdout#7
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 catsubcommand that prints memo content to stdout. With no argument it prints<memo>/scratch.txt; with a topic argument it prints<memo>/topics/<topic>.md. Read-only — no git operations are performed. Builds the second primitive (afterzemo ls) for the search/discovery flow that delegates filtering to terminal-side search such as WezTerm QuickSearch.Related issue
Closes #4
Changes
Command.cat: ?[]const u8variant incli.zig; routed fromparseArgs(handleszemo catandzemo cat <topic>) and dispatched inrun.doCat(env → file path resolution) andprintFile(path-based, testable) helpers.paths.isValidTopic(rejects path-traversal, dots, spaces, multibyte) with a friendly stderr message and exit code 1.zemo: no such file: <path>to stderr, exit 1 (standardcat-like behaviour).Io.Reader.streamRemainingso memory usage is bounded by a 4 KiB read buffer regardless of file size.zemo catto Features and Usage sections.zemo catandzemo cat <topic>lines.Testing
zig build testpasses locallyzig build run -- cat zemoprints~/memo/topics/zemo.mdzig build run -- catprints scratchzig build run -- cat doesnotexist→ stderrzemo: no such file: ...and exit 1zig build -Dtarget=x86_64-windows/-Dtarget=x86_64-macosNew tests added:
parseArgs: cat without topic/parseArgs: cat with topic/parseArgs: cat too many args— parser-levelprintFile: prints file contents to stdout— integration test usingstd.testing.tmpDirandIo.Writer.Allocatingto capture outputprintFile: missing file → exit 1, stderr message— verifies error path and exit codeNotes for reviewers
printFilewas extracted fromdoCatto keep the testable surface path-based (mirrors thelistTopics/doLssplit from feat: addzemo lsto list topics #6).doCatrather thanparseArgs, matching the existing pattern forzemo <topic>(openTopic). This keepsparseArgspayload-agnostic and consolidates user-facing validation messages in the dispatcher.ZEMO_DIRfix from feat: addzemo lsto list topics #6 (centralized inpaths.memoDir) carries over for free —doCatcallspaths.memoDirand benefits from the absolute-path normalization.