Skip to content

feat(drive): add get command #64

@rianjs

Description

@rianjs

Summary

Add gro drive get command to retrieve detailed metadata for a specific file.

Usage

gro drive get <file-id>        # Show file details
gro drive get <file-id> --json # JSON output

Flags

Flag Short Default Description
--json -j false Output as JSON

Implementation

Files to Create/Modify

  • internal/cmd/drive/get.go - Get command implementation
  • internal/cmd/drive/get_test.go - Unit tests
  • internal/cmd/drive/drive.go - Register get subcommand
  • internal/drive/files.go - Add GetFile() method if not complete

Drive API Call

// Request all relevant fields
file, err := srv.Files.Get(fileID).
    Fields("id,name,mimeType,size,createdTime,modifiedTime,owners,parents,webViewLink,shared,sharingUser,permissions").
    Do()

Fields to Display

Field Description
ID File ID
Name File name
Type Human-readable type (Document, Spreadsheet, PDF, etc.)
Size File size (N/A for Google Docs)
Created Creation timestamp
Modified Last modified timestamp
Owner Owner email(s)
Shared Whether file is shared
Web Link URL to open in browser
Parent Folder Parent folder ID(s)

Text Output Format

File Details
────────────────────────────────────────
ID:           1abc2def3ghij4klmnop
Name:         Q4 Budget Report
Type:         Google Document
Size:         -
Created:      2024-01-10 09:30:00
Modified:     2024-01-15 14:22:00
Owner:        john@example.com
Shared:       Yes
Web Link:     https://docs.google.com/document/d/1abc.../edit
Parent:       0BwwA4oUTeiV1UVNwOTl (My Drive)

JSON Output

{
  "id": "1abc2def3ghij4klmnop",
  "name": "Q4 Budget Report",
  "mimeType": "application/vnd.google-apps.document",
  "createdTime": "2024-01-10T09:30:00Z",
  "modifiedTime": "2024-01-15T14:22:00Z",
  "owners": ["john@example.com"],
  "shared": true,
  "webViewLink": "https://docs.google.com/document/d/1abc.../edit",
  "parents": ["0BwwA4oUTeiV1UVNwOTl"]
}

Acceptance Criteria

  • Shows all relevant metadata
  • Handles Google Docs (no size) gracefully
  • Handles regular files (with size)
  • JSON output includes all fields
  • Returns clear error for invalid file ID
  • make verify passes

Blocked By

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions