Skip to content

feat: add docs comments subcommand for managing Google Doc comments#263

Merged
steipete merged 3 commits intosteipete:mainfrom
alextnetto:feat/docs-comments
Feb 14, 2026
Merged

feat: add docs comments subcommand for managing Google Doc comments#263
steipete merged 3 commits intosteipete:mainfrom
alextnetto:feat/docs-comments

Conversation

@alextnetto
Copy link
Copy Markdown
Contributor

@alextnetto alextnetto commented Feb 14, 2026

Motivation

When working with Google Docs through gog, there's no way to interact with comments from the docs command tree. While gog drive comments exists with full CRUD support, it's not discoverable when you're in a gog docs workflow, and it lacks some doc-specific conveniences like filtering resolved comments by default.

This PR adds gog docs comments as a doc-centric interface for managing comments, following the same pattern as docs export and docs copy which delegate to Drive API functionality.

What's New

A full gog docs comments command tree with 6 subcommands:

gog docs comments list <docId>              # List open comments (resolved filtered by default)
gog docs comments list <docId> --include-resolved  # Include resolved comments
gog docs comments get <docId> <commentId>   # Get a comment with full details + replies
gog docs comments add <docId> "text"        # Add a comment
gog docs comments add <docId> "text" --quoted "highlighted text"  # Anchor to text
gog docs comments reply <docId> <commentId> "reply text"  # Reply to a comment
gog docs comments resolve <docId> <commentId>  # Mark as done
gog docs comments resolve <docId> <commentId> -m "Fixed"  # Resolve with message
gog docs comments delete <docId> <commentId>  # Delete a comment

Key differences from drive comments

Feature drive comments list docs comments list
Resolved comments Shows all Filters resolved by default
Quoted text Requires --include-quoted Always shown
Resolve command Not available docs comments resolve
URL input Bare IDs only Accepts Doc URLs via normalizeGoogleID

Example output

Plain text (default):

ID    AUTHOR   QUOTED                  CONTENT                    CREATED              RESOLVED  REPLIES
c1    Alice    The quick brown fox     Needs revision             2025-06-01 10:00     false     1
c3    Dave     Introduction section    Consider rewording this    2025-06-01 12:00     false     0

JSON (--json):

{
  "docId": "1BxiMVs0XRA...",
  "comments": [
    {
      "id": "c1",
      "author": {"displayName": "Alice"},
      "content": "Needs revision",
      "quotedFileContent": {"value": "The quick brown fox"},
      "createdTime": "2025-06-01T10:00:00Z",
      "resolved": false,
      "replies": [...]
    }
  ],
  "nextPageToken": ""
}

Implementation

  • New file: internal/cmd/docs_comments.go — all 6 subcommands
  • New file: internal/cmd/docs_comments_test.go — thorough tests
  • Modified: internal/cmd/docs.go — added Comments field to DocsCmd

Patterns followed

  • Uses shared helpers: collectAllPages, tableWriter, formatDateTime, truncateString, normalizeGoogleID, failEmptyExit, dryRunExit, confirmDestructive
  • Same auth/token flow as all other commands
  • Consistent output: --json for machine-readable, tabwriter for human-readable
  • Pagination support: --max, --page, --all
  • Validation follows same usage() pattern
  • resolve uses Drive API reply with action: "resolve" per Google's docs

Tests

  • Integration tests via Execute() covering JSON + plain text for all subcommands
  • Resolved filtering tested: default (open only) vs --include-resolved
  • Empty results handling
  • Validation errors for all missing required arguments
  • Unit tests for filterOpenComments including edge cases (nil, all open, all resolved)

Add a full `gog docs comments` command tree that provides a
doc-centric interface for managing comments on Google Docs via
the Drive API v3 comments endpoint.

Subcommands:
  list    - List comments (filters resolved by default, --include-resolved to show all)
  get     - Get a single comment with full details including replies
  add     - Add a comment, optionally anchored to quoted text
  reply   - Reply to a comment
  resolve - Resolve a comment (mark as done), with optional message
  delete  - Delete a comment

Key differences from `drive comments`:
- `list` filters resolved comments by default (--include-resolved to include)
- `list` always shows quoted text column (no separate flag needed)
- `resolve` subcommand (drive comments has no equivalent)
- Accepts Google Doc URLs in addition to bare IDs (via normalizeGoogleID)
- Doc-centric naming and help text

Follows existing patterns: uses shared helpers (collectAllPages,
tableWriter, formatDateTime, truncateString, normalizeGoogleID,
failEmptyExit, dryRunExit, confirmDestructive), same auth/token
flow, consistent output formatting.
@alextnetto alextnetto changed the title feat: add docs comments subcommand feat: add docs comments subcommand for managing Google Doc comments Feb 14, 2026
@steipete steipete merged commit 49af127 into steipete:main Feb 14, 2026
1 check passed
@steipete
Copy link
Copy Markdown
Owner

Landed (squash) onto main.

Thanks @alextnetto!

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.

2 participants