From 82dbff282d4eefe7a7125f4393eef2d2eee3beb5 Mon Sep 17 00:00:00 2001 From: Lakelezz <12222135+Lakelezz@users.noreply.github.com> Date: Fri, 14 Sep 2018 15:46:36 +0200 Subject: Add `Usage Sample`-field back to help. (#388) --- src/framework/standard/help_commands.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/framework') 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, usage: Option, + usage_sample: Option, } /// 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); -- cgit v1.2.3