gws-cli 1.6.1__tar.gz → 1.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gws_cli-1.6.1 → gws_cli-1.7.0}/LIVE_TESTING.md +29 -14
- {gws_cli-1.6.1 → gws_cli-1.7.0}/PKG-INFO +1 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/SKILL.md +4 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/pyproject.toml +1 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/drive.md +4 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/gmail.md +6 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/sheets.md +12 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/__init__.py +1 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/auth/oauth.py +3 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/auth/provider.py +24 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/auth/server.py +6 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/gmail.py +6 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/sheets.py +62 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/base.py +18 -2
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/convert.py +2 -2
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/drive.py +19 -1
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/gmail.py +37 -3
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/sheets.py +53 -3
- gws_cli-1.7.0/tests/test_drive_feedback.py +83 -0
- gws_cli-1.7.0/tests/test_gmail_reply_draft.py +186 -0
- gws_cli-1.7.0/tests/test_implicit_login.py +165 -0
- gws_cli-1.7.0/tests/test_sheets_batch_write.py +117 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/.gitignore +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/CLAUDE.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/LICENSE +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/README.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/SKILL-advanced.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/SKILL-typesetting.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/TESTING.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/calendar.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/contacts.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/docs.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/reference/slides.md +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/__main__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/auth/__init__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/auth/scopes.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/cli.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/__init__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/_account.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/account.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/auth.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/calendar.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/config.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/contacts.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/convert.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/docs.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/drive.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/commands/slides.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/config.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/context.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/crypto.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/exceptions.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/output.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/__init__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/calendar.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/contacts.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/docs.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/services/slides.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/utils/__init__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/utils/colors.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/utils/diagrams.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/utils/retry.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/src/gws/utils/security.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/__init__.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/conftest.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_account_commands.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_account_enforcement.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_auth_accounts.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_auth_commands.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_auth_provider.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_config_accounts.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_config_runtime_state.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_crypto.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_docs.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_download_screening.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_font_size.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_force_reauth.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_gmail_mime.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_headless_auth.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_headless_env.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_output.py +0 -0
- {gws_cli-1.6.1 → gws_cli-1.7.0}/tests/test_server_auth.py +0 -0
|
@@ -8,10 +8,10 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
8
8
|
|
|
9
9
|
| Metric | Count | Notes |
|
|
10
10
|
|--------|-------|-------|
|
|
11
|
-
| Pass |
|
|
11
|
+
| Pass | 221 | |
|
|
12
12
|
| Skip | 7 | Destructive or require external setup (e.g. target email, ownership transfer) |
|
|
13
13
|
| Expected fail | 1 | API correctly rejects the operation (e.g. unsubscribe from owned calendar) |
|
|
14
|
-
| **Total** | **
|
|
14
|
+
| **Total** | **229** | |
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -25,10 +25,10 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
25
25
|
| 4 | Infra |`gws-cli config`|PASS| 2026-02-05 |Shows all config including multi-account|
|
|
26
26
|
| 5 | Infra |`gws-cli config list`|PASS| 2026-02-05 |8/8 services enabled|
|
|
27
27
|
| 6 | Drive |`drive list --max 5`|PASS| 2026-02-05 |Pagination works|
|
|
28
|
-
| 7 | Drive |`drive search "name contains 'GWS-Test'"`|PASS| 2026-
|
|
29
|
-
| 8 | Drive |`drive get <file_id>`|PASS| 2026-
|
|
28
|
+
| 7 | Drive |`drive search "name contains 'GWS-Test'"`|PASS| 2026-11-16 |Query works|
|
|
29
|
+
| 8 | Drive |`drive get <file_id>`|PASS| 2026-11-16 |Full metadata incl. `last_modifying_user`|
|
|
30
30
|
| 9 | Drive |`drive download <file_id> /tmp/...`|PASS| 2026-02-05 |File downloaded|
|
|
31
|
-
| 10 | Drive |`drive export <doc_id> --format "application/pdf"`|PASS| 2026-
|
|
31
|
+
| 10 | Drive |`drive export <doc_id> --format "application/pdf"`|PASS| 2026-11-16 |PDF and xlsx exported|
|
|
32
32
|
| 11 | Drive |`drive changes-token`|PASS| 2026-02-05 |Returns start_page_token|
|
|
33
33
|
| 12 | Drive |`drive list-changes <token>`|PASS| 2026-02-05 |Lists changes|
|
|
34
34
|
| 13 | Drive |`drive list-trash --max 5`|PASS| 2026-02-05 |Shows trashed files|
|
|
@@ -38,16 +38,16 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
38
38
|
| 17 | Drive |`drive list-revisions <file_id>`|FIXED| 2026-02-05 |Bug: `supportsAllDrives` not valid for revisions API|
|
|
39
39
|
| 18 | Drive |`drive list-comments <file_id>`|PASS| 2026-02-05 |Works|
|
|
40
40
|
| 19 | Drive |`drive list-replies <file_id> <comment_id>`|PASS| 2026-02-05 |Lists comment replies|
|
|
41
|
-
| 20 | Drive |`drive create-folder "..."`|PASS| 2026-
|
|
42
|
-
| 21 | Drive |`drive upload <path> --folder <id>`|PASS| 2026-
|
|
41
|
+
| 20 | Drive |`drive create-folder "..."`|PASS| 2026-11-16 |Created test folder|
|
|
42
|
+
| 21 | Drive |`drive upload <path> --folder <id>`|PASS| 2026-11-16 |File uploaded|
|
|
43
43
|
| 22 | Drive |`drive copy <id> --name "..."`|PASS| 2026-02-05 |File copied|
|
|
44
|
-
| 23 | Drive |`drive move <id> <folder_id>`|PASS| 2026-
|
|
44
|
+
| 23 | Drive |`drive move <id> <folder_id>`|PASS| 2026-11-16 |File moved|
|
|
45
45
|
| 24 | Drive |`drive update <id> <path>`|PASS| 2026-02-05 |Content updated|
|
|
46
46
|
| 25 | Drive |`drive add-comment <id> "..."`|PASS| 2026-02-05 |Comment added|
|
|
47
47
|
| 26 | Drive |`drive reply-to-comment <id> <cid> "..."`|PASS| 2026-02-05 |Reply created|
|
|
48
48
|
| 27 | Drive |`drive resolve-comment <id> <cid>`|FIXED| 2026-02-05 |Bug: was using `comments().update()`, fixed to `replies().create()` with `action: "resolve"`|
|
|
49
49
|
| 28 | Drive |`drive delete-comment <id> <cid>`|PASS| 2026-02-05 |Comment deleted|
|
|
50
|
-
| 29 | Drive |`drive delete <id>`|PASS| 2026-
|
|
50
|
+
| 29 | Drive |`drive delete <id>`|PASS| 2026-11-16 |File trashed|
|
|
51
51
|
| 30 | Drive |`drive restore <id>`|PASS| 2026-02-05 |File restored|
|
|
52
52
|
| 31 | Drive |`drive share`|SKIP| 2026-02-05 |Requires target email|
|
|
53
53
|
| 32 | Drive |`drive update-permission`|SKIP| 2026-02-05 |Requires target email|
|
|
@@ -99,10 +99,10 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
99
99
|
| 78 | Docs |`docs rename-tab <id> <tab_id> "New"`|FIXED| 2026-02-05 |Bug: `tabId` placed outside `tabProperties`|
|
|
100
100
|
| 79 | Docs |`docs reorder-tab <id> <tab_id> 0`|FIXED| 2026-02-05 |Bug: same `tabId` placement issue|
|
|
101
101
|
| 80 | Docs |`docs delete-tab <id> <tab_id>`|PASS| 2026-02-05 |Tab deleted|
|
|
102
|
-
| 81 | Sheets |`sheets metadata <id>`|PASS| 2026-
|
|
102
|
+
| 81 | Sheets |`sheets metadata <id>`|PASS| 2026-11-16 |Full metadata incl. `last_modifying_user`|
|
|
103
103
|
| 82 | Sheets |`sheets read <id> "Sheet1\!A1:C5"`|PASS| 2026-02-05 |Read range|
|
|
104
|
-
| 83 | Sheets |`sheets batch-get <id> "A1:B2,C1:D2"`|PASS| 2026-
|
|
105
|
-
| 84 | Sheets |`sheets create "Title" --sheets "S1,S2"`|PASS| 2026-
|
|
104
|
+
| 83 | Sheets |`sheets batch-get <id> "A1:B2,C1:D2"`|PASS| 2026-11-16 |Batch read|
|
|
105
|
+
| 84 | Sheets |`sheets create "Title" --sheets "S1,S2"`|PASS| 2026-11-16 |Creates spreadsheet|
|
|
106
106
|
| 85 | Sheets |`sheets write <id> "A1:C3" --values '[...]'`|PASS| 2026-02-05 |Write values|
|
|
107
107
|
| 86 | Sheets |`sheets append <id> "A:C" --values '[...]'`|PASS| 2026-02-05 |Append values|
|
|
108
108
|
| 87 | Sheets |`sheets clear <id> "A10:C10"`|PASS| 2026-02-05 |Clear range|
|
|
@@ -190,8 +190,8 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
190
190
|
| 169 | Gmail |`gmail search "subject:GWS-Test"`|PASS| 2026-02-05 |Search works|
|
|
191
191
|
| 170 | Gmail |`gmail get-label INBOX`|PASS| 2026-02-05 |Returns label details with counts|
|
|
192
192
|
| 171 | Gmail |`gmail history <history_id> --max 5`|PASS| 2026-02-05 |Returns history|
|
|
193
|
-
| 172 | Gmail |`gmail send <to> "Subject" "Body"`|PASS| 2026-
|
|
194
|
-
| 173 | Gmail |`gmail reply <message_id> "Reply body"`|FIXED| 2026-
|
|
193
|
+
| 172 | Gmail |`gmail send <to> "Subject" "Body"`|PASS| 2026-11-16 |Email sent|
|
|
194
|
+
| 173 | Gmail |`gmail reply <message_id> "Reply body"`|FIXED| 2026-11-16 |Bug: case-insensitive headers + format="full" needed|
|
|
195
195
|
| 174 | Gmail |`gmail mark-read <message_id>`|PASS| 2026-02-05 |Marked read|
|
|
196
196
|
| 175 | Gmail |`gmail mark-unread <message_id>`|PASS| 2026-02-05 |Marked unread|
|
|
197
197
|
| 176 | Gmail |`gmail add-star <message_id>`|PASS| 2026-02-05 |Starred|
|
|
@@ -237,6 +237,17 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
237
237
|
| 216 | Convert |`convert md-to-pdf /tmp/test.md /tmp/out.pdf`|PASS| 2026-02-06 |Markdown to PDF (35KB)|
|
|
238
238
|
| 217 | Convert |`convert md-to-slides /tmp/test.md -t "Title"`|PASS| 2026-02-06 |Markdown to Slides|
|
|
239
239
|
| 218 | Infra |`gws-cli auth --headless`|SKIP| 2026-10-14 |Needs interactive browser consent; covered by unit tests. Contributor-verified on a headless server|
|
|
240
|
+
| 219 | Infra |implicit login, no TTY (`drive list` with no token)|PASS| 2026-11-16 |Fails fast: `AUTH_ERROR` JSON, exit 1, ~1s (previously hung waiting for OAuth)|
|
|
241
|
+
| 220 | Drive |`drive list -f <empty_folder_id>`|PASS| 2026-11-16 |Visible empty folder: success, `file_count` 0|
|
|
242
|
+
| 221 | Drive |`drive list -f <inaccessible_id>`|PASS| 2026-11-16 |`NOT_FOUND`, exit 4 (previously empty success)|
|
|
243
|
+
| 222 | Sheets |`sheets batch-write <id> --stdin`|PASS| 2026-11-16 |Two disjoint ranges in one call; `USER_ENTERED` evaluates formulas|
|
|
244
|
+
| 223 | Sheets |`sheets metadata <xlsx_file_id>`|PASS| 2026-11-16 |Office file in Drive: `API_ERROR` with `drive download` hint|
|
|
245
|
+
| 224 | Gmail |`gmail reply <message_id> "Body" --draft`|PASS| 2026-11-16 |Draft created in the original thread; nothing sent|
|
|
246
|
+
| 225 | Gmail |`gmail get-draft <draft_id>`|PASS| 2026-11-16 |Returns draft body and recipients|
|
|
247
|
+
| 226 | Gmail |`gmail update-draft <reply_draft_id> --body "..."`|PASS| 2026-11-16 |Edited reply draft stays in its thread|
|
|
248
|
+
| 227 | Gmail |`gmail get-thread <thread_id>`|PASS| 2026-11-16 |Lists original + draft|
|
|
249
|
+
| 228 | Gmail |`gmail delete-draft <draft_id>`|PASS| 2026-11-16 |Draft deleted|
|
|
250
|
+
| 229 | Gmail |`gmail trash-thread <thread_id>`|PASS| 2026-11-16 |Thread trashed|
|
|
240
251
|
|
|
241
252
|
---
|
|
242
253
|
|
|
@@ -256,6 +267,9 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
256
267
|
| 10 | Docs | paragraph-border | Missing required `padding` field in border style | Added `padding: {magnitude: 6.0, unit: "PT"}` |
|
|
257
268
|
| 11 | Slides | set-speaker-notes | `deleteText` fails when notes are empty | Check text existence before deleting |
|
|
258
269
|
| 12 | Slides | transform-element | Non-invertible matrix when only `scaleX` set | Default unset `scaleX`/`scaleY` to 1.0 |
|
|
270
|
+
| 13 | Infra | any command | Revoked/missing token started an OAuth flow that hung forever without a terminal | Implicit logins fail fast with `AUTH_ERROR` when stderr is not a TTY |
|
|
271
|
+
| 14 | Drive | list -f | Folder not visible to the account returned an empty success | Empty first page checks the folder; `NOT_FOUND` if not visible |
|
|
272
|
+
| 15 | Gmail | update-draft | Rebuilt message dropped `threadId`/`In-Reply-To`/`References` | Carry them over from the current draft |
|
|
259
273
|
|
|
260
274
|
---
|
|
261
275
|
|
|
@@ -275,3 +289,4 @@ Manual testing of all CLI operations against real Google Workspace accounts.
|
|
|
275
289
|
| 2026-02-05 | Initial test run: Infra, Drive, Docs, Sheets, Slides, Gmail. Fixed 10 bugs. |
|
|
276
290
|
| 2026-02-06 | Completed: Calendar, Contacts, Convert. Fixed 2 bugs (Slides). All 217 tests done. |
|
|
277
291
|
| 2026-10-14 | Added `auth --headless` (#218) from PR #1. Unit-tested (redirect validation, PKCE exchange, no secret echo); live test pending. |
|
|
292
|
+
| 2026-11-16 | Live-tested agent-feedback fixes (#219-#229) on throwaway files and a self-addressed email, all cleaned up: implicit-login fail-fast, `drive list -f` visibility check, `last_modifying_user`, `sheets batch-write`, Office-file hint, `gmail reply --draft`, `update-draft` keeps threading. Re-tested related commands. Fixed a doubled period in the Office-file hint. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gws-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Google Workspace CLI - Unified management for Docs, Sheets, Slides, Drive, Gmail, Calendar, and Contacts
|
|
5
5
|
Project-URL: Homepage, https://github.com/andmarios/google-workspace-skill
|
|
6
6
|
Project-URL: Repository, https://github.com/andmarios/google-workspace-skill
|
|
@@ -235,6 +235,9 @@ cat <<'EOF' | uvx gws-cli sheets write <spreadsheet_id> "A1:C4" --stdin
|
|
|
235
235
|
]
|
|
236
236
|
EOF
|
|
237
237
|
|
|
238
|
+
# Write several disjoint ranges in one call (JSON: range -> rows)
|
|
239
|
+
echo '{"Sheet1!B2:C2": [["a","b"]], "Sheet1!E23": [["x"]]}' | uvx gws-cli sheets batch-write <spreadsheet_id> --stdin
|
|
240
|
+
|
|
238
241
|
# Read data back
|
|
239
242
|
uvx gws-cli sheets read <spreadsheet_id> "A1:C10"
|
|
240
243
|
|
|
@@ -325,7 +328,7 @@ All commands use `uvx gws-cli <service> <command>`. Authentication is automatic
|
|
|
325
328
|
|
|
326
329
|
## Authentication
|
|
327
330
|
|
|
328
|
-
> **Important**: `gws-cli auth` (including `--force` and `--headless`) must be run by the user in their own terminal, not from Claude Code. Normal mode opens a browser. On a headless server, use `--headless`: in local mode the user pastes the final loopback redirect URL into the CLI's hidden prompt; in server-relay mode it uses device login instead. That redirect URL contains a one-time authorization code, so **never ask the user to paste it into the chat**.
|
|
331
|
+
> **Important**: `gws-cli auth` (including `--force` and `--headless`) must be run by the user in their own terminal, not from Claude Code. Outside a terminal, any other command whose token is missing, expired or revoked fails fast with an `AUTH_ERROR` naming the `gws-cli auth` command for the user to run, instead of starting a login. Normal mode opens a browser. On a headless server, use `--headless`: in local mode the user pastes the final loopback redirect URL into the CLI's hidden prompt; in server-relay mode it uses device login instead. That redirect URL contains a one-time authorization code, so **never ask the user to paste it into the chat**.
|
|
329
332
|
|
|
330
333
|
```bash
|
|
331
334
|
uvx gws-cli auth # Authenticate using the configured mode (opens browser)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gws-cli"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.7.0"
|
|
8
8
|
description = "Google Workspace CLI - Unified management for Docs, Sheets, Slides, Drive, Gmail, Calendar, and Contacts"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
# List files (default: 10)
|
|
19
19
|
uvx gws-cli drive list --max 20
|
|
20
20
|
|
|
21
|
+
# List a folder's contents (NOT_FOUND, exit 4, if the folder is missing or not visible to this account)
|
|
22
|
+
uvx gws-cli drive list -f <folder_id>
|
|
23
|
+
|
|
21
24
|
# Search files
|
|
22
25
|
uvx gws-cli drive search "name contains 'report'"
|
|
23
26
|
|
|
24
|
-
# Get file metadata
|
|
27
|
+
# Get file metadata (includes last_modifying_user; owners/permissions are empty for shared-drive files)
|
|
25
28
|
uvx gws-cli drive get <file_id>
|
|
26
29
|
|
|
27
30
|
# Download file (--force to skip prompt-injection screening)
|
|
@@ -59,6 +59,10 @@ uvx gws-cli gmail reply <message_id> "Reply body" --cc "a@x.com,b@y.com" --bcc "
|
|
|
59
59
|
uvx gws-cli gmail reply <message_id> "Reply body" --all
|
|
60
60
|
uvx gws-cli gmail reply <message_id> "Reply body" --all --cc "extra@x.com"
|
|
61
61
|
|
|
62
|
+
# Draft a reply in the thread instead of sending (works with --all/--cc/--bcc).
|
|
63
|
+
# Output includes draft_id and "draft": true; send later with send-draft.
|
|
64
|
+
uvx gws-cli gmail reply <message_id> "Reply body" --draft
|
|
65
|
+
|
|
62
66
|
# Mark as read/unread
|
|
63
67
|
uvx gws-cli gmail mark-read <message_id>
|
|
64
68
|
uvx gws-cli gmail mark-unread <message_id>
|
|
@@ -159,6 +163,8 @@ spanning multiple lines.
|
|
|
159
163
|
Add formatting as needed.
|
|
160
164
|
EOF
|
|
161
165
|
|
|
166
|
+
# To draft a reply in an existing thread, use `reply --draft` (see Basic Operations)
|
|
167
|
+
|
|
162
168
|
# Update a draft
|
|
163
169
|
uvx gws-cli gmail update-draft <draft_id> --subject "New Subject" --body "Updated body"
|
|
164
170
|
|
|
@@ -53,6 +53,14 @@ EOF
|
|
|
53
53
|
jq -n '[["Name","Score"],["Alice",95],["Bob",87]]' | \
|
|
54
54
|
uvx gws-cli sheets write <spreadsheet_id> "A1:B3" --stdin
|
|
55
55
|
|
|
56
|
+
# Write several disjoint ranges in one request (JSON object: A1 range -> array of rows)
|
|
57
|
+
cat <<'EOF' | uvx gws-cli sheets batch-write <spreadsheet_id> --stdin
|
|
58
|
+
{
|
|
59
|
+
"Sheet1!B2:C3": [["Widget A", 15000], ["Widget B", 22000]],
|
|
60
|
+
"Sheet1!E23": [["=SUM(C2:C3)"]]
|
|
61
|
+
}
|
|
62
|
+
EOF
|
|
63
|
+
|
|
56
64
|
# Append rows
|
|
57
65
|
uvx gws-cli sheets append <spreadsheet_id> "A1:C1" --values '[["New","Row","Data"]]'
|
|
58
66
|
|
|
@@ -63,6 +71,10 @@ uvx gws-cli sheets clear <spreadsheet_id> "A1:C10"
|
|
|
63
71
|
uvx gws-cli sheets batch-get <spreadsheet_id> "A1:B5,C1:D5"
|
|
64
72
|
```
|
|
65
73
|
|
|
74
|
+
`batch-write` takes the range map via `--stdin` or `--values '<json>'` and sends every range in one `spreadsheets.values.batchUpdate` call. Like `write`, values use `USER_ENTERED` input (formulas are evaluated and strings like `"15000"` are parsed as numbers). It returns `ranges` (the updated ranges) and the `updated_rows`/`updated_columns`/`updated_cells` totals.
|
|
75
|
+
|
|
76
|
+
If `metadata`, `read` or `batch-get` fail with "This operation is not supported for this document", the file is probably an Office file (e.g. `.xlsx`) stored in Drive rather than a Google Sheet; the error includes a hint to fetch it with `gws-cli drive download <id> <output_path>`.
|
|
77
|
+
|
|
66
78
|
## Sheet Management
|
|
67
79
|
|
|
68
80
|
```bash
|
|
@@ -15,7 +15,7 @@ from google_auth_oauthlib.flow import InstalledAppFlow
|
|
|
15
15
|
from oauthlib.oauth2 import OAuth2Error
|
|
16
16
|
from requests.exceptions import RequestException
|
|
17
17
|
|
|
18
|
-
from gws.auth.provider import headless_requested
|
|
18
|
+
from gws.auth.provider import guard_implicit_login, headless_requested
|
|
19
19
|
from gws.auth.scopes import get_scopes_for_services
|
|
20
20
|
from gws.config import Config
|
|
21
21
|
from gws.crypto import delete_encrypted, load_encrypted, save_encrypted
|
|
@@ -136,6 +136,7 @@ class LocalAuthProvider:
|
|
|
136
136
|
self,
|
|
137
137
|
force_refresh: bool = False,
|
|
138
138
|
headless: bool = False,
|
|
139
|
+
implicit: bool = False,
|
|
139
140
|
) -> Credentials:
|
|
140
141
|
"""Get valid credentials, triggering auth flow if needed."""
|
|
141
142
|
headless = headless_requested(headless)
|
|
@@ -175,6 +176,7 @@ class LocalAuthProvider:
|
|
|
175
176
|
|
|
176
177
|
# Run auth flow if no valid credentials
|
|
177
178
|
if not self._credentials or not self._credentials.valid:
|
|
179
|
+
guard_implicit_login(implicit, self._account_name)
|
|
178
180
|
self._run_auth_flow(scopes, headless=headless, consent=force_refresh)
|
|
179
181
|
|
|
180
182
|
return self._credentials # type: ignore
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
+
import sys
|
|
6
7
|
from pathlib import Path
|
|
7
8
|
from typing import Any, Protocol, runtime_checkable
|
|
8
9
|
from urllib.parse import urlparse
|
|
@@ -22,8 +23,13 @@ class AuthProvider(Protocol):
|
|
|
22
23
|
self,
|
|
23
24
|
force_refresh: bool = False,
|
|
24
25
|
headless: bool = False,
|
|
26
|
+
implicit: bool = False,
|
|
25
27
|
) -> Credentials:
|
|
26
|
-
"""Get valid Google API credentials, triggering auth if needed.
|
|
28
|
+
"""Get valid Google API credentials, triggering auth if needed.
|
|
29
|
+
|
|
30
|
+
implicit: called by a service command rather than `auth`; a login that
|
|
31
|
+
needs a human then fails fast when stderr is not a terminal.
|
|
32
|
+
"""
|
|
27
33
|
...
|
|
28
34
|
|
|
29
35
|
def delete_token(self) -> bool:
|
|
@@ -60,6 +66,23 @@ def headless_requested(explicit: bool = False) -> bool:
|
|
|
60
66
|
return explicit or value in {"1", "true", "yes", "on"}
|
|
61
67
|
|
|
62
68
|
|
|
69
|
+
def guard_implicit_login(implicit: bool, account: str | None) -> None:
|
|
70
|
+
"""Refuse an implicit login nobody can complete (agent, CI: stderr not a TTY).
|
|
71
|
+
|
|
72
|
+
Without this, a command with a revoked token waits forever for a browser
|
|
73
|
+
callback or pasted URL. Call right before each step that needs a human.
|
|
74
|
+
"""
|
|
75
|
+
if not implicit or sys.stderr.isatty():
|
|
76
|
+
return
|
|
77
|
+
from gws.exceptions import AuthError
|
|
78
|
+
|
|
79
|
+
command = f"gws-cli auth --account {account}" if account else "gws-cli auth"
|
|
80
|
+
raise AuthError(
|
|
81
|
+
"Not authenticated (token missing, expired or revoked).",
|
|
82
|
+
f"Run '{command}' in your own terminal to authenticate.",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
63
86
|
def _validate_server_url(url: str) -> None:
|
|
64
87
|
"""Require HTTPS for non-localhost relay server URLs."""
|
|
65
88
|
from gws.exceptions import AuthError
|
|
@@ -16,7 +16,7 @@ from urllib.parse import urlencode, urlparse
|
|
|
16
16
|
import httpx
|
|
17
17
|
from google.oauth2.credentials import Credentials
|
|
18
18
|
|
|
19
|
-
from gws.auth.provider import headless_requested
|
|
19
|
+
from gws.auth.provider import guard_implicit_login, headless_requested
|
|
20
20
|
from gws.config import Config
|
|
21
21
|
from gws.crypto import delete_encrypted, load_encrypted, save_encrypted
|
|
22
22
|
from gws.exceptions import AuthError
|
|
@@ -122,6 +122,7 @@ class ServerAuthProvider:
|
|
|
122
122
|
self,
|
|
123
123
|
force_refresh: bool = False,
|
|
124
124
|
headless: bool = False,
|
|
125
|
+
implicit: bool = False,
|
|
125
126
|
) -> Credentials:
|
|
126
127
|
"""Get valid Google API credentials via the server relay.
|
|
127
128
|
|
|
@@ -142,6 +143,9 @@ class ServerAuthProvider:
|
|
|
142
143
|
|
|
143
144
|
# Refresh if expired
|
|
144
145
|
if self._credentials and self._credentials.expired and self._credentials.refresh_token:
|
|
146
|
+
if not self._load_server_token():
|
|
147
|
+
# The refresh would first auto-start an interactive relay login.
|
|
148
|
+
guard_implicit_login(implicit, self._account_name)
|
|
145
149
|
try:
|
|
146
150
|
self._refresh_via_server(self._credentials.refresh_token, headless=headless)
|
|
147
151
|
return self._credentials # Set by _refresh_via_server
|
|
@@ -158,6 +162,7 @@ class ServerAuthProvider:
|
|
|
158
162
|
|
|
159
163
|
# Full flow: start → browser → complete
|
|
160
164
|
if not self._credentials or not self._credentials.valid:
|
|
165
|
+
guard_implicit_login(implicit, self._account_name)
|
|
161
166
|
self._run_server_auth_flow(headless=headless)
|
|
162
167
|
|
|
163
168
|
return self._credentials # type: ignore[return-value]
|
|
@@ -150,11 +150,16 @@ def reply_to_message(
|
|
|
150
150
|
bool,
|
|
151
151
|
typer.Option("--all", help="Reply to all: include original To/Cc (minus yourself)."),
|
|
152
152
|
] = False,
|
|
153
|
+
draft: Annotated[
|
|
154
|
+
bool,
|
|
155
|
+
typer.Option("--draft", help="Save the reply as a draft in the thread instead of sending."),
|
|
156
|
+
] = False,
|
|
153
157
|
) -> None:
|
|
154
158
|
"""Reply to an existing message (HTML by default, stays in-thread).
|
|
155
159
|
|
|
156
160
|
Use --all to reply to everyone (original To + Cc, excluding yourself);
|
|
157
161
|
--cc/--bcc add recipients and are unioned with --all.
|
|
162
|
+
Use --draft to save the threaded reply as a draft instead of sending it.
|
|
158
163
|
"""
|
|
159
164
|
if stdin:
|
|
160
165
|
body = sys.stdin.read()
|
|
@@ -176,6 +181,7 @@ def reply_to_message(
|
|
|
176
181
|
cc=cc,
|
|
177
182
|
bcc=bcc,
|
|
178
183
|
reply_all=reply_all,
|
|
184
|
+
draft=draft,
|
|
179
185
|
)
|
|
180
186
|
|
|
181
187
|
|
|
@@ -125,6 +125,68 @@ def write_values(
|
|
|
125
125
|
)
|
|
126
126
|
|
|
127
127
|
|
|
128
|
+
@app.command("batch-write")
|
|
129
|
+
def batch_write(
|
|
130
|
+
spreadsheet_id: Annotated[str, typer.Argument(help="Spreadsheet ID.")],
|
|
131
|
+
stdin: Annotated[
|
|
132
|
+
bool,
|
|
133
|
+
typer.Option("--stdin", help="Read the range map as JSON from stdin."),
|
|
134
|
+
] = False,
|
|
135
|
+
values: Annotated[
|
|
136
|
+
Optional[str],
|
|
137
|
+
typer.Option("--values", "-v", help="JSON object mapping A1 range to rows."),
|
|
138
|
+
] = None,
|
|
139
|
+
) -> None:
|
|
140
|
+
"""Write values to multiple ranges in one request.
|
|
141
|
+
|
|
142
|
+
Values should be a JSON object mapping A1 range to an array of rows,
|
|
143
|
+
e.g., '{"Sheet1!A1:B1": [["a", "b"]], "Sheet1!D5": [["x"]]}'
|
|
144
|
+
"""
|
|
145
|
+
if stdin:
|
|
146
|
+
raw = sys.stdin.read()
|
|
147
|
+
elif values:
|
|
148
|
+
raw = values
|
|
149
|
+
else:
|
|
150
|
+
output_error(
|
|
151
|
+
error_code="INVALID_ARGS",
|
|
152
|
+
operation="sheets.batch_write",
|
|
153
|
+
message="Either --stdin or --values required",
|
|
154
|
+
)
|
|
155
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
data = json.loads(raw)
|
|
159
|
+
except json.JSONDecodeError as e:
|
|
160
|
+
output_error(
|
|
161
|
+
error_code="INVALID_ARGS",
|
|
162
|
+
operation="sheets.batch_write",
|
|
163
|
+
message=f"Invalid JSON input: {e}",
|
|
164
|
+
)
|
|
165
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
166
|
+
|
|
167
|
+
# JSON object keys are always strings, so only the container and value shapes need checking.
|
|
168
|
+
if not (
|
|
169
|
+
isinstance(data, dict)
|
|
170
|
+
and data
|
|
171
|
+
and all(
|
|
172
|
+
isinstance(rows, list) and all(isinstance(row, list) for row in rows)
|
|
173
|
+
for rows in data.values()
|
|
174
|
+
)
|
|
175
|
+
):
|
|
176
|
+
output_error(
|
|
177
|
+
error_code="INVALID_ARGS",
|
|
178
|
+
operation="sheets.batch_write",
|
|
179
|
+
message=(
|
|
180
|
+
"Expected a non-empty JSON object mapping A1 range to an array of rows, "
|
|
181
|
+
'e.g. {"Sheet1!A1:B1": [["a", "b"]], "Sheet1!D5": [["x"]]}'
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
185
|
+
|
|
186
|
+
service = SheetsService()
|
|
187
|
+
service.batch_write(spreadsheet_id=spreadsheet_id, data=data)
|
|
188
|
+
|
|
189
|
+
|
|
128
190
|
@app.command("append")
|
|
129
191
|
def append_values(
|
|
130
192
|
spreadsheet_id: Annotated[str, typer.Argument(help="Spreadsheet ID.")],
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
from abc import ABC
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
+
from google.oauth2.credentials import Credentials
|
|
6
7
|
from googleapiclient.discovery import build, Resource
|
|
7
8
|
|
|
8
9
|
from gws.auth.provider import AuthProvider, resolve_auth_provider
|
|
9
10
|
from gws.context import get_active_account
|
|
11
|
+
from gws.exceptions import AuthError, ExitCode
|
|
12
|
+
from gws.output import output_error
|
|
10
13
|
from gws.utils.retry import execute_with_retry
|
|
11
14
|
|
|
12
15
|
|
|
@@ -22,11 +25,24 @@ class BaseService(ABC):
|
|
|
22
25
|
self._service: Resource | None = None
|
|
23
26
|
self._drive_service: Resource | None = None
|
|
24
27
|
|
|
28
|
+
def _get_credentials(self) -> Credentials:
|
|
29
|
+
"""Get credentials for a service command; auth errors exit with JSON, not a traceback."""
|
|
30
|
+
try:
|
|
31
|
+
return self.auth_manager.get_credentials(implicit=True)
|
|
32
|
+
except AuthError as e:
|
|
33
|
+
output_error(
|
|
34
|
+
error_code="AUTH_ERROR",
|
|
35
|
+
operation="auth",
|
|
36
|
+
message=str(e),
|
|
37
|
+
details=e.details,
|
|
38
|
+
)
|
|
39
|
+
raise SystemExit(ExitCode.AUTH_ERROR)
|
|
40
|
+
|
|
25
41
|
@property
|
|
26
42
|
def service(self) -> Resource:
|
|
27
43
|
"""Lazy-load the Google API service."""
|
|
28
44
|
if self._service is None:
|
|
29
|
-
credentials = self.
|
|
45
|
+
credentials = self._get_credentials()
|
|
30
46
|
self._service = build(
|
|
31
47
|
self.SERVICE_NAME,
|
|
32
48
|
self.VERSION,
|
|
@@ -42,6 +58,6 @@ class BaseService(ABC):
|
|
|
42
58
|
def drive_service(self) -> Resource:
|
|
43
59
|
"""Lazy-load Drive service (used by multiple services)."""
|
|
44
60
|
if self._drive_service is None:
|
|
45
|
-
credentials = self.
|
|
61
|
+
credentials = self._get_credentials()
|
|
46
62
|
self._drive_service = build("drive", "v3", credentials=credentials)
|
|
47
63
|
return self._drive_service
|
|
@@ -32,7 +32,7 @@ class ConvertService(BaseService):
|
|
|
32
32
|
def docs_service(self) -> Resource:
|
|
33
33
|
"""Lazy-load Docs service for document manipulation."""
|
|
34
34
|
if self._docs_service is None:
|
|
35
|
-
credentials = self.
|
|
35
|
+
credentials = self._get_credentials()
|
|
36
36
|
self._docs_service = build("docs", "v1", credentials=credentials)
|
|
37
37
|
return self._docs_service
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ class ConvertService(BaseService):
|
|
|
40
40
|
def slides_service(self) -> Resource:
|
|
41
41
|
"""Lazy-load Slides service for presentation creation."""
|
|
42
42
|
if self._slides_service is None:
|
|
43
|
-
credentials = self.
|
|
43
|
+
credentials = self._get_credentials()
|
|
44
44
|
self._slides_service = build("slides", "v1", credentials=credentials)
|
|
45
45
|
return self._slides_service
|
|
46
46
|
|
|
@@ -276,6 +276,12 @@ class DriveService(BaseService):
|
|
|
276
276
|
|
|
277
277
|
files = [self._file_to_dict(f) for f in result.get("files", [])]
|
|
278
278
|
|
|
279
|
+
if folder_id and not files and page_token is None:
|
|
280
|
+
# Drive returns an empty list (not 404) for a folder this account can't see.
|
|
281
|
+
self.execute(self.service.files().get(
|
|
282
|
+
fileId=folder_id, fields="id", supportsAllDrives=True
|
|
283
|
+
))
|
|
284
|
+
|
|
279
285
|
output_external_content(
|
|
280
286
|
operation="drive.list",
|
|
281
287
|
source_type="document",
|
|
@@ -286,6 +292,13 @@ class DriveService(BaseService):
|
|
|
286
292
|
)
|
|
287
293
|
return result
|
|
288
294
|
except HttpError as e:
|
|
295
|
+
if folder_id and e.resp.status == 404:
|
|
296
|
+
output_error(
|
|
297
|
+
error_code="NOT_FOUND",
|
|
298
|
+
operation="drive.list",
|
|
299
|
+
message=f"Folder not found or not accessible to this account: {folder_id}",
|
|
300
|
+
)
|
|
301
|
+
raise SystemExit(ExitCode.NOT_FOUND)
|
|
289
302
|
output_error(
|
|
290
303
|
error_code="API_ERROR",
|
|
291
304
|
operation="drive.list",
|
|
@@ -341,7 +354,7 @@ class DriveService(BaseService):
|
|
|
341
354
|
fields = (
|
|
342
355
|
"id, name, mimeType, webViewLink, webContentLink, parents, "
|
|
343
356
|
"createdTime, modifiedTime, size, description, starred, trashed, "
|
|
344
|
-
"owners, permissions"
|
|
357
|
+
"owners, permissions, lastModifyingUser(displayName,emailAddress)"
|
|
345
358
|
)
|
|
346
359
|
file = self.execute(self.service.files().get(
|
|
347
360
|
fileId=file_id, fields=fields, supportsAllDrives=True
|
|
@@ -368,6 +381,11 @@ class DriveService(BaseService):
|
|
|
368
381
|
file_data["trashed"] = file.get("trashed")
|
|
369
382
|
file_data["owners"] = owners
|
|
370
383
|
file_data["permissions"] = permissions
|
|
384
|
+
modifier = file.get("lastModifyingUser")
|
|
385
|
+
file_data["last_modifying_user"] = (
|
|
386
|
+
{"email": modifier.get("emailAddress"), "name": modifier.get("displayName")}
|
|
387
|
+
if modifier else None
|
|
388
|
+
)
|
|
371
389
|
|
|
372
390
|
output_external_content(
|
|
373
391
|
operation="drive.get_metadata",
|
|
@@ -344,12 +344,15 @@ class GmailService(BaseService):
|
|
|
344
344
|
cc: str | None = None,
|
|
345
345
|
bcc: str | None = None,
|
|
346
346
|
reply_all: bool = False,
|
|
347
|
+
draft: bool = False,
|
|
347
348
|
) -> dict[str, Any]:
|
|
348
349
|
"""Reply to an existing message (stays threaded via In-Reply-To/References).
|
|
349
350
|
|
|
350
351
|
By default replies only to the sender. With reply_all=True, also
|
|
351
352
|
addresses the original To recipients and Cc's the original Cc list,
|
|
352
353
|
excluding your own address. Explicit cc/bcc are unioned in.
|
|
354
|
+
With draft=True, saves the reply as a draft in the thread instead of
|
|
355
|
+
sending it.
|
|
353
356
|
"""
|
|
354
357
|
try:
|
|
355
358
|
# Unescape shell-escaped characters
|
|
@@ -419,14 +422,36 @@ class GmailService(BaseService):
|
|
|
419
422
|
if bcc_value:
|
|
420
423
|
message["bcc"] = bcc_value
|
|
421
424
|
|
|
422
|
-
# Set references for threading
|
|
425
|
+
# Set references for threading (RFC 5322: parent's References + its Message-ID)
|
|
423
426
|
message_id_header = ci_headers.get("message-id", "")
|
|
424
427
|
if message_id_header:
|
|
425
428
|
message["In-Reply-To"] = message_id_header
|
|
426
|
-
|
|
429
|
+
parent_refs = ci_headers.get("references", "")
|
|
430
|
+
message["References"] = f"{parent_refs} {message_id_header}".strip()
|
|
427
431
|
|
|
428
432
|
raw = base64.urlsafe_b64encode(message.as_bytes()).decode("utf-8")
|
|
429
433
|
|
|
434
|
+
if draft:
|
|
435
|
+
result = self.execute(
|
|
436
|
+
self.service.users()
|
|
437
|
+
.drafts()
|
|
438
|
+
.create(
|
|
439
|
+
userId="me",
|
|
440
|
+
body={"message": {"raw": raw, "threadId": thread_id}},
|
|
441
|
+
)
|
|
442
|
+
)
|
|
443
|
+
draft_message = result.get("message", {})
|
|
444
|
+
output_success(
|
|
445
|
+
operation="gmail.reply",
|
|
446
|
+
draft=True,
|
|
447
|
+
draft_id=result["id"],
|
|
448
|
+
message_id=draft_message.get("id"),
|
|
449
|
+
thread_id=draft_message.get("threadId", thread_id),
|
|
450
|
+
to=reply_to,
|
|
451
|
+
subject=message["subject"],
|
|
452
|
+
)
|
|
453
|
+
return result
|
|
454
|
+
|
|
430
455
|
result = self.execute(
|
|
431
456
|
self.service.users()
|
|
432
457
|
.messages()
|
|
@@ -937,7 +962,16 @@ class GmailService(BaseService):
|
|
|
937
962
|
if final_bcc:
|
|
938
963
|
message["bcc"] = final_bcc
|
|
939
964
|
|
|
965
|
+
# Keep reply drafts (from `reply --draft`) in their thread
|
|
966
|
+
if current_headers.get("in-reply-to"):
|
|
967
|
+
message["In-Reply-To"] = current_headers["in-reply-to"]
|
|
968
|
+
if current_headers.get("references"):
|
|
969
|
+
message["References"] = current_headers["references"]
|
|
970
|
+
|
|
940
971
|
raw = base64.urlsafe_b64encode(message.as_bytes()).decode("utf-8")
|
|
972
|
+
draft_message = {"raw": raw}
|
|
973
|
+
if current_msg.get("threadId"):
|
|
974
|
+
draft_message["threadId"] = current_msg["threadId"]
|
|
941
975
|
|
|
942
976
|
result = self.execute(
|
|
943
977
|
self.service.users()
|
|
@@ -945,7 +979,7 @@ class GmailService(BaseService):
|
|
|
945
979
|
.update(
|
|
946
980
|
userId="me",
|
|
947
981
|
id=draft_id,
|
|
948
|
-
body={"message":
|
|
982
|
+
body={"message": draft_message},
|
|
949
983
|
)
|
|
950
984
|
)
|
|
951
985
|
|