diff --git a/.changeset/fix-draft-send-tip.md b/.changeset/fix-draft-send-tip.md new file mode 100644 index 000000000..31730db14 --- /dev/null +++ b/.changeset/fix-draft-send-tip.md @@ -0,0 +1,5 @@ +--- +"@googleworkspace/cli": patch +--- + +Fix the Gmail draft tip so its generated send command uses valid subcommands and request flags. diff --git a/crates/google-workspace-cli/src/helpers/gmail/mod.rs b/crates/google-workspace-cli/src/helpers/gmail/mod.rs index caeb8b6b0..1593ff719 100644 --- a/crates/google-workspace-cli/src/helpers/gmail/mod.rs +++ b/crates/google-workspace-cli/src/helpers/gmail/mod.rs @@ -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\":\"\"}'"; /// Strip ASCII control characters (0x00–0x1F, 0x7F) from a string. /// @@ -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\":\"\"}}'"); + eprintln!(" {DRAFT_SEND_TIP_COMMAND}"); } Ok(()) @@ -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\":\"\"}'" + ); + } + #[test] fn test_append_address_list_header_value() { let mut header_value = String::new();