Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-draft-send-tip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Fix the Gmail draft tip so its generated send command uses valid subcommands and request flags.
12 changes: 11 additions & 1 deletion crates/google-workspace-cli/src/helpers/gmail/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub struct GmailHelper;
pub(super) const GMAIL_SCOPE: &str = "https://www.googleapis.com/auth/gmail.modify";
pub(super) const GMAIL_READONLY_SCOPE: &str = "https://www.googleapis.com/auth/gmail.readonly";
pub(super) const PUBSUB_SCOPE: &str = "https://www.googleapis.com/auth/pubsub";
const DRAFT_SEND_TIP_COMMAND: &str =
"gws gmail users drafts send --params '{\"userId\":\"me\"}' --json '{\"id\":\"<draft-id>\"}'";

/// Strip ASCII control characters (0x00–0x1F, 0x7F) from a string.
///
Expand Down Expand Up @@ -1488,7 +1490,7 @@ pub(super) async fn dispatch_raw_email(

if draft && !matches.get_flag("dry-run") {
eprintln!("Tip: copy the draft \"id\" from the response above, then send with:");
eprintln!(" gws gmail users.drafts.send --body '{{\"id\":\"<draft-id>\"}}'");
eprintln!(" {DRAFT_SEND_TIP_COMMAND}");
}

Ok(())
Expand Down Expand Up @@ -2360,6 +2362,14 @@ mod tests {
assert!(parsed["message"].get("threadId").is_none());
}

#[test]
fn test_draft_send_tip_uses_discovery_command_syntax() {
assert_eq!(
DRAFT_SEND_TIP_COMMAND,
"gws gmail users drafts send --params '{\"userId\":\"me\"}' --json '{\"id\":\"<draft-id>\"}'"
);
}

#[test]
fn test_append_address_list_header_value() {
let mut header_value = String::new();
Expand Down
Loading