Skip to content

Commit 75615ea

Browse files
committed
Unify help for workqueue Zulip commands
1 parent 0f14a19 commit 75615ea

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/zulip.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ async fn process_zulip_request(ctx: &Context, req: Request) -> anyhow::Result<Op
148148
handle_command(ctx, gh_id, &req.data, &req.message).await
149149
}
150150

151+
const WORKQUEUE_HELP: &str = r#"`work show`: show your assigned PRs
152+
`work set-pr-limit <number>|unlimited`: set the maximum number of PRs you can be assigned to
153+
`work set-rotation-mode <off|on>`: configure if you are *on* rotation or *off* rotation (e.g. when you are on a vacation)"#;
154+
151155
fn handle_command<'a>(
152156
ctx: &'a Context,
153157
gh_id: anyhow::Result<u64>,
@@ -179,7 +183,7 @@ fn handle_command<'a>(
179183
Some("meta") => add_meta_notification(&ctx, gh_id, words).await
180184
.map_err(|e| format_err!("Failed to parse `meta` command. Synopsis: meta <num> <text>: Add <text> to your notification identified by <num> (>0)\n\nError: {e:?}")),
181185
Some("work") => workqueue_commands(ctx, gh_id, words).await
182-
.map_err(|e| format_err!("Failed to parse `work` command. Synopsis: work <show>: shows your current PRs assignment\n\nError: {e:?}")),
186+
.map_err(|e| format_err!("Failed to parse `work` command. Help: {WORKQUEUE_HELP}\n\nError: {e:?}")),
183187
_ => {
184188
while let Some(word) = next {
185189
if word == "@**triagebot**" {
@@ -333,7 +337,7 @@ async fn workqueue_commands(
333337
)?)
334338
}
335339
}
336-
None => anyhow::bail!("Missing parameter. See `work help` for more information."),
340+
None => anyhow::bail!("Missing parameter."),
337341
};
338342
upsert_review_prefs(
339343
&db_client,
@@ -361,29 +365,29 @@ async fn workqueue_commands(
361365
match value {
362366
"on" => RotationMode::OnRotation,
363367
"off" => RotationMode::OffRotation,
364-
_ => anyhow::bail!("Unknown rotation mode {value}. Use `on` or `off`.")
368+
_ => anyhow::bail!("Unknown rotation mode {value}. Use `on` or `off`."),
365369
}
366370
}
367-
None => anyhow::bail!("Missing parameter. See `work help` for more information."),
371+
None => anyhow::bail!("Missing parameter."),
368372
};
369373
upsert_review_prefs(
370374
&db_client,
371375
user,
372376
review_prefs.and_then(|p| p.max_assigned_prs.map(|v| v as u32)),
373377
rotation_mode,
374378
)
375-
.await
376-
.context("Error occurred while setting review preferences.")?;
379+
.await
380+
.context("Error occurred while setting review preferences.")?;
377381
tracing::info!("Setting rotation mode `{gh_username}` to {rotation_mode:?}");
378382
format!(
379-
"Rotation mode set to {rotation_mode:?}"
383+
"Rotation mode set to {}",
384+
match rotation_mode {
385+
RotationMode::OnRotation => "*on rotation*",
386+
RotationMode::OffRotation => "*off rotation*.",
387+
}
380388
)
381389
}
382-
"help" => r"`work show`: show your assigned PRs
383-
`work set-pr-limit <number>|unlimited`: set the maximum number of PRs you can be assigned to
384-
`work set-rotation-mode <off|on>`: configure if you are *on* rotation or *off* rotation (e.g. when you are on a vacation)
385-
"
386-
.to_string(),
390+
"help" => WORKQUEUE_HELP.to_string(),
387391
_ => anyhow::bail!("Invalid subcommand."),
388392
};
389393

0 commit comments

Comments
 (0)