feat: Add JSON input support for contacts update#200
feat: Add JSON input support for contacts update#200jrossi wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Adds --from-file flag to 'gog contacts update' command, enabling updates
from JSON files or stdin. This provides full access to Google People API
fields (URLs, notes, addresses, birthdays, etc.) without requiring
individual CLI flags for each field.
Usage:
gog contacts get people/c123 --json > contact.json
# Edit contact.json to add/modify fields
gog contacts update people/c123 --from-file=contact.json
# Or pipe directly:
gog contacts get people/c123 --json | \
jq '.contact.urls += [{"value": "https://example.com"}]' | \
gog contacts update people/c123 --from-file=-
Benefits:
- Supports all Google People API fields
- Future-proof (new fields work automatically)
- Scriptable with jq and other JSON tools
- Enables complex nested structure updates
---
🤖 This PR was generated with AI assistance (Claude Code).
The implementation was reviewed and tested by the contributor.
The read mask for 'contacts get' now includes additional fields that can be updated via JSON input: urls, biographies, addresses, organizations. This ensures fields written via --from-file are visible when reading the contact back. Tested: - Added Obsidian URI via JSON file - verified in contact - Added biography via stdin pipe - verified in contact
|
I completely understand that many of the pull requests are AI-generated. If you want me to pull this and remove it, no problem. It serves my purpose. It will lead to confirmed work and the outcomes I want. I don't want to flood you if you don't want this. No problem. I completely understand. Thank you. Great PR, great tool. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca9d8fe7f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if len(person.EmailAddresses) > 0 { | ||
| updateFields = append(updateFields, "emailAddresses") |
There was a problem hiding this comment.
Include empty list fields in JSON update masks
This branch only adds emailAddresses to updatePersonFields when the slice is non-empty, so a JSON edit that intentionally clears emails (for example setting "emailAddresses": [] after contacts get --json) will not be sent to the API as a clear operation. The same pattern is used for the other repeated fields, which makes --from-file unable to remove existing values and can lead to unexpected no-op updates.
Useful? React with 👍 / 👎.
| return outfmt.WriteJSON(os.Stdout, map[string]any{"contact": updated}) | ||
| } | ||
| u.Out().Printf("resource\t%s", updated.ResourceName) | ||
| u.Out().Println("✓ Updated from JSON") |
There was a problem hiding this comment.
Keep human-only success text off stdout
The new ✓ Updated from JSON line is emitted on stdout in plain mode, which changes contacts update from a single parseable key\tvalue record to mixed machine/human output. Scripts that consume stdout now need special-casing for --from-file; this status hint should go to stderr to preserve stable parseable stdout behavior.
Useful? React with 👍 / 👎.
Supersedes #200. - Add `contacts update --from-file <path|->` + `--ignore-etag` - Update mask from JSON keys; clears via `[]`/`null` - ETag safety + resourceName validation - Docs/tests/README/CHANGELOG updates Co-authored-by: Jeremy Rossi <jeremy@jeremyrossi.com>
|
Landed via #253 (squash merge). What changed vs this PR:
Thanks for the original implementation and live testing, @jrossi. |
Supersedes openclaw#200. - Add `contacts update --from-file <path|->` + `--ignore-etag` - Update mask from JSON keys; clears via `[]`/`null` - ETag safety + resourceName validation - Docs/tests/README/CHANGELOG updates Co-authored-by: Jeremy Rossi <jeremy@jeremyrossi.com>
Summary
Adds
--from-fileflag togog contacts updatecommand, enabling contact updates from JSON files or stdin. This provides full access to all Google People API fields without requiring individual CLI flags.Motivation
Currently,
gog contacts updateonly supports a limited set of fields via CLI flags (--given,--family,--email,--phone). Many useful fields like URLs, notes/biographies, addresses, and birthdays are not accessible.Instead of adding individual flags for every possible field, this PR implements a more flexible JSON-based approach.
Testing
✅ Fully tested with real Google Contacts:
See full PR description at: #200
🤖 AI-Generated: Implemented with Claude Code, fully tested by contributor