Skip to content

Commit 2268a2b

Browse files
StarefossenCopilot
andcommitted
style: apply rustfmt to email module
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 77cbb10 commit 2268a2b

4 files changed

Lines changed: 31 additions & 33 deletions

File tree

src/commands/sponsors/email.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use dialoguer::{Confirm, FuzzySelect, Select};
77
use super::args::EmailArgs;
88
use crate::client::TrpcClient;
99
use crate::template;
10-
use crate::types::{
11-
SendEmailResponse, SponsorEmailTemplate, TemplateListResponse,
12-
};
10+
use crate::types::{SendEmailResponse, SponsorEmailTemplate, TemplateListResponse};
1311
use crate::ui;
1412

1513
pub async fn run(args: EmailArgs) -> Result<()> {
@@ -19,10 +17,7 @@ pub async fn run(args: EmailArgs) -> Result<()> {
1917
let template_resp = fetch_templates(&client, &args.id).await?;
2018
sp.finish_and_clear();
2119

22-
let sponsor_name = template_resp
23-
.sponsor_name
24-
.as_deref()
25-
.unwrap_or("Unknown");
20+
let sponsor_name = template_resp.sponsor_name.as_deref().unwrap_or("Unknown");
2621

2722
let is_interactive = console::Term::stdout().is_term() && args.message.is_none();
2823

@@ -36,10 +31,9 @@ pub async fn run(args: EmailArgs) -> Result<()> {
3631
} else if is_interactive {
3732
pick_template_interactive(&args, &template_resp, sponsor_name)?
3833
} else {
39-
let slug = args
40-
.template
41-
.as_deref()
42-
.ok_or_else(|| anyhow::anyhow!("--template or --message required in non-interactive mode"))?;
34+
let slug = args.template.as_deref().ok_or_else(|| {
35+
anyhow::anyhow!("--template or --message required in non-interactive mode")
36+
})?;
4337
pick_template_by_slug(&args, &template_resp, slug)?
4438
};
4539

@@ -84,7 +78,15 @@ pub async fn run(args: EmailArgs) -> Result<()> {
8478
}
8579
}
8680

87-
send_email(&client, &args, &args.id, &subject, &body, &recipients_display).await
81+
send_email(
82+
&client,
83+
&args,
84+
&args.id,
85+
&subject,
86+
&body,
87+
&recipients_display,
88+
)
89+
.await
8890
}
8991

9092
fn pick_template_interactive(
@@ -96,11 +98,7 @@ fn pick_template_interactive(
9698
bail!("No email templates found. Create templates in the web UI first.");
9799
}
98100

99-
let items: Vec<String> = resp
100-
.templates
101-
.iter()
102-
.map(format_template_item)
103-
.collect();
101+
let items: Vec<String> = resp.templates.iter().map(format_template_item).collect();
104102

105103
let default_idx = if let Some(ref slug) = args.template {
106104
resp.templates
@@ -167,7 +165,11 @@ fn format_template_item(t: &SponsorEmailTemplate) -> String {
167165
crate::types::TemplateLanguage::English => "🇬🇧",
168166
crate::types::TemplateLanguage::Unknown => " ",
169167
};
170-
let default_marker = if t.is_default == Some(true) { " ★" } else { "" };
168+
let default_marker = if t.is_default == Some(true) {
169+
" ★"
170+
} else {
171+
""
172+
};
171173
format!(
172174
"{} {:<30} {:<16}{}",
173175
lang,
@@ -310,9 +312,7 @@ async fn send_email(
310312
"body": body,
311313
});
312314

313-
let result: SendEmailResponse = client
314-
.mutate("sponsor.crm.sendEmailBySfc", &input)
315-
.await?;
315+
let result: SendEmailResponse = client.mutate("sponsor.crm.sendEmailBySfc", &input).await?;
316316
sp.finish_and_clear();
317317

318318
if args.json {

src/template.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,18 @@ mod tests {
122122

123123
#[test]
124124
fn find_unresolved_single() {
125-
assert_eq!(
126-
find_unresolved_variables("Hello {{{NAME}}}!"),
127-
vec!["NAME"]
128-
);
125+
assert_eq!(find_unresolved_variables("Hello {{{NAME}}}!"), vec!["NAME"]);
129126
}
130127

131128
#[test]
132129
fn find_unresolved_multiple() {
133-
let result =
134-
find_unresolved_variables("{{{A}}} and {{{B}}} with {{{C}}}");
130+
let result = find_unresolved_variables("{{{A}}} and {{{B}}} with {{{C}}}");
135131
assert_eq!(result, vec!["A", "B", "C"]);
136132
}
137133

138134
#[test]
139135
fn find_unresolved_deduplicates() {
140-
let result =
141-
find_unresolved_variables("{{{NAME}}} is {{{NAME}}}");
136+
let result = find_unresolved_variables("{{{NAME}}} is {{{NAME}}}");
142137
assert_eq!(result, vec!["NAME"]);
143138
}
144139

src/types/email_template.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ mod tests {
299299

300300
#[test]
301301
fn language_display() {
302-
assert!(TemplateLanguage::Norwegian.to_string().contains("Norwegian"));
302+
assert!(
303+
TemplateLanguage::Norwegian
304+
.to_string()
305+
.contains("Norwegian")
306+
);
303307
assert!(TemplateLanguage::English.to_string().contains("English"));
304308
}
305309
}

tests/e2e.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,8 @@ async fn email_send_unauthorized_e2e() {
591591
"subject": "Test",
592592
"body": "Test body",
593593
});
594-
let result: Result<cnctl::types::SendEmailResponse, _> = client
595-
.mutate("sponsor.crm.sendEmailBySfc", &input)
596-
.await;
594+
let result: Result<cnctl::types::SendEmailResponse, _> =
595+
client.mutate("sponsor.crm.sendEmailBySfc", &input).await;
597596

598597
assert!(result.is_err());
599598
let err = result.unwrap_err().to_string();

0 commit comments

Comments
 (0)