1.4 KiB
1.4 KiB
| summary | read_when | ||
|---|---|---|---|
| Drive-backed export commands (Docs/Slides/Sheets) |
|
Exports (Drive-backed)
Goal: one implementation for “export Google Thing via Drive”.
Current pattern
- Shared builder:
internal/cmd/export_via_drive.go:newExportViaDriveCmd - Shared download:
internal/cmd/drive.go:downloadDriveFile(handles Drive “native” exports + normal files)
Each service command is a thin wrapper:
gog docs export <docId> --format pdf|docx|txtgog slides export <presentationId> --format pdf|pptxgog sheets export <spreadsheetId> --format pdf|xlsx|csv
Conventions
- Arg is always the Drive file id (Doc/Sheet/Slides id).
- Type guard: compare
mimeTypeand error withfile is not a <KindLabel> (mimeType="..."). --outdefaults to$(os.UserConfigDir())/gogcli/drive-downloads/(viainternal/config:EnsureDriveDownloadsDir).--outcan be dir or explicit file path (viainternal/cmd/drive_download_helpers.go:resolveDriveDownloadDestPath).- Output
--json:{ "path": "...", "size": <bytes> }- text:
path\t.../size\t...
Add a new export command
- Pick expected Drive mime type + allowed formats.
- Add a new
newXExportCmdcallingnewExportViaDriveCmd(...). - Add/extend tests in
internal/cmd/execute_drive_*_test.gostyle (fake Drive server).