Skip to content
Closed
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-gmail-draft-send-tip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Correct the Gmail draft send command shown by the `--draft` helper.
14 changes: 13 additions & 1 deletion crates/google-workspace-cli/src/helpers/gmail/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,10 @@ fn build_send_metadata(thread_id: Option<&str>, draft: bool) -> Option<String> {
}
}

fn draft_send_tip() -> &'static str {
"gws gmail users drafts send --params '{\"userId\":\"me\"}' --json '{\"id\":\"<draft-id>\"}'"
}

pub(super) async fn dispatch_raw_email(
doc: &crate::discovery::RestDescription,
matches: &ArgMatches,
Expand Down Expand Up @@ -1488,7 +1492,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());
}

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

#[test]
fn test_draft_send_tip_uses_valid_discovery_command_syntax() {
assert_eq!(
draft_send_tip(),
"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