diff options
| author | Lakelezz <[email protected]> | 2018-09-14 15:46:36 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-09-14 15:46:36 +0200 |
| commit | 82dbff282d4eefe7a7125f4393eef2d2eee3beb5 (patch) | |
| tree | ee0c760a8b1d792262bba98eb8a769a99640e4ac | |
| parent | Change default branch to 'current' (diff) | |
| download | serenity-82dbff282d4eefe7a7125f4393eef2d2eee3beb5.tar.xz serenity-82dbff282d4eefe7a7125f4393eef2d2eee3beb5.zip | |
Add `Usage Sample`-field back to help. (#388)
| -rw-r--r-- | src/framework/standard/help_commands.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/framework/standard/help_commands.rs b/src/framework/standard/help_commands.rs index ccd1e51..4953b21 100644 --- a/src/framework/standard/help_commands.rs +++ b/src/framework/standard/help_commands.rs @@ -97,6 +97,7 @@ pub struct Command<'a> { availability: &'a str, description: Option<String>, usage: Option<String>, + usage_sample: Option<String>, } /// Contains possible suggestions in case a command could not be found @@ -410,6 +411,7 @@ fn fetch_single_command<'a, H: BuildHasher>( aliases: command.aliases.clone(), availability: available_text, usage: command.usage.clone(), + usage_sample: command.example.clone(), }, }); } @@ -653,8 +655,14 @@ fn send_single_command_embed( embed = embed.description(desc); } - if let &Some(ref usage_sample) = &command.usage { - embed = embed.field(&help_options.usage_label, usage_sample, true); + if let &Some(ref usage) = &command.usage { + embed = embed.field(&help_options.usage_label, usage, true); + } + + if let Some(ref usage_sample) = command.usage_sample { + let value = format!("`{} {}`", command.name, usage_sample); + + embed = embed.field(&help_options.usage_sample_label, value, true); } embed = embed.field(&help_options.grouped_label, command.group_name, true); @@ -792,6 +800,10 @@ fn single_command_to_plain_string(help_options: &HelpOptions, command: &Command) let _ = writeln!(result, "**{}**: {}", help_options.usage_label, usage); } + if let &Some(ref usage_sample) = &command.usage_sample { + let _ = writeln!(result, "**{}**: `{} {}`", help_options.usage_sample_label, command.name, usage_sample); + } + let _ = writeln!(result, "**{}**: {}", help_options.grouped_label, command.group_name); let _ = writeln!(result, "**{}**: {}", help_options.available_text, command.availability); |