Skip to content

feat(document): add edit subcommand#55

Merged
gugahoi merged 1 commit into
mainfrom
feat/doc-edit-command
Jun 25, 2026
Merged

feat(document): add edit subcommand#55
gugahoi merged 1 commit into
mainfrom
feat/doc-edit-command

Conversation

@gugahoi

@gugahoi gugahoi commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add firestore document edit <path> (alias e) to modify existing documents from the CLI.
  • Interactive mode (no flags): opens the document's contents as JSON in $EDITOR (falls back to $VISUAL, then vim/vi/nano); on save, validates and full-replaces the document via Set.
  • Non-interactive mode (--set field=value, repeatable): partial-merges only the named fields via firestore Update, leaving siblings untouched. Supports dotted paths (address.city=NYC) and auto-typed values (number/bool/JSON-array/string; quote to force a string).
  • Errors with document not found if the document doesn't exist (it's edit, not create).

Test plan

  • go build -o firestore . passes
  • go test ./... passes (unit tests cover parseValue / parseSetArg)
  • make integration-test passes (emulator tests cover partial merge, dotted paths, arrays, and not-found for the non-interactive path)
  • Interactive mode is exercised manually (EDITOR=vim firestore doc edit <path>); not covered by automated tests since it needs a real editor.

Notes

  • detectEditor is a small (~12 line) duplication of the helper in pkg/cmd/browse/editor.go — kept local on purpose so this lightweight command doesn't pull in the Bubble Tea TUI dependency. Marked with a ponytail: comment noting the extract-to-shared path if a third caller appears.

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.
@gugahoi
gugahoi merged commit 83b2ae6 into main Jun 25, 2026
2 checks passed
@gugahoi
gugahoi deleted the feat/doc-edit-command branch June 25, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant