Skip to content

Commit b4761bb

Browse files
committed
Improve appearance of render help
1 parent 9c25d7d commit b4761bb

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

crates/bot/src/bot.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,26 +197,21 @@ fn render_help() -> String {
197197

198198
format!(
199199
"\
200-
Render the given code as an image.
200+
Render Typst code as an image.
201201
202202
Syntax: `?render [pagesize=<page size>] [theme=<theme>] <code block> [...]`
203203
204204
**Flags**
205-
206205
- `pagesize` can be `preview` (default), `auto`, or `default`.
207-
208206
- `theme` can be `dark` (default), `light`, or `transparent`.
209207
210208
To be clear, the full default preamble is:
211-
212209
```
213210
{default_preamble}
214211
```
215-
216212
To remove the preamble entirely, use `pagesize=default theme=transparent`.
217213
218214
**Examples**
219-
220215
```
221216
?render `hello, world!`
222217
@@ -288,7 +283,6 @@ impl<'a> poise::PopArgument<'a> for Rest {
288283
}
289284
}
290285

291-
/// Render Typst code as an image.
292286
#[poise::command(
293287
prefix_command,
294288
track_edits,
@@ -299,11 +293,9 @@ impl<'a> poise::PopArgument<'a> for Rest {
299293
)]
300294
async fn render(
301295
ctx: Context<'_>,
302-
#[description = "Flags"] flags: RenderFlags,
303-
#[description = "Code to render"] code: CodeBlock,
304-
#[rename = "rest"]
305-
#[description = "Extra message content"]
306-
_: Rest,
296+
flags: RenderFlags,
297+
code: CodeBlock,
298+
#[rename = "rest"] _: Rest,
307299
) -> Result<(), PoiseError> {
308300
let pool = &ctx.data().pool;
309301

@@ -384,6 +376,13 @@ async fn help(
384376
ctx: Context<'_>,
385377
#[description = "Specific command to show help about"] command: Option<String>,
386378
) -> Result<(), PoiseError> {
379+
// Avoid the useless parameter list from `poise::builtins::help`.
380+
if command.as_deref() == Some("render") {
381+
// We prefer `reply` but `poise::builtins::help` uses `say`, so be consistent.
382+
ctx.say(format!("`?render`\n\n{}", render_help())).await?;
383+
return Ok(());
384+
}
385+
387386
let config = poise::builtins::HelpConfiguration {
388387
extra_text_at_bottom: "\
389388
Type ?help command for more info on a command.

0 commit comments

Comments
 (0)