feat(document): add edit subcommand#55
Merged
Merged
Conversation
Add `firestore document edit <path>` with two modes: - interactive: open $EDITOR with the document's JSON, full-replace on save - non-interactive: --set field=value (repeatable) partial-merges named fields via firestore Update, supports dotted paths and auto-typed values Errors if the document does not exist. Covered by unit tests for the value parser and integration tests for the non-interactive merge path.
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
firestore document edit <path>(aliase) to modify existing documents from the CLI.$EDITOR(falls back to$VISUAL, thenvim/vi/nano); on save, validates and full-replaces the document viaSet.--set field=value, repeatable): partial-merges only the named fields via firestoreUpdate, leaving siblings untouched. Supports dotted paths (address.city=NYC) and auto-typed values (number/bool/JSON-array/string; quote to force a string).document not foundif the document doesn't exist (it's edit, not create).Test plan
go build -o firestore .passesgo test ./...passes (unit tests coverparseValue/parseSetArg)make integration-testpasses (emulator tests cover partial merge, dotted paths, arrays, and not-found for the non-interactive path)EDITOR=vim firestore doc edit <path>); not covered by automated tests since it needs a real editor.Notes
detectEditoris a small (~12 line) duplication of the helper inpkg/cmd/browse/editor.go— kept local on purpose so this lightweight command doesn't pull in the Bubble Tea TUI dependency. Marked with aponytail:comment noting the extract-to-shared path if a third caller appears.