summaryrefslogtreecommitdiff
path: root/lib/gitlab/slash_commands/presenters/help.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/slash_commands/presenters/help.rb')
-rw-r--r--lib/gitlab/slash_commands/presenters/help.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/slash_commands/presenters/help.rb b/lib/gitlab/slash_commands/presenters/help.rb
new file mode 100644
index 00000000000..ea611a4d629
--- /dev/null
+++ b/lib/gitlab/slash_commands/presenters/help.rb
@@ -0,0 +1,27 @@
+module Gitlab
+ module SlashCommands
+ module Presenters
+ class Help < Presenters::Base
+ def present(trigger, text)
+ ephemeral_response(text: help_message(trigger, text))
+ end
+
+ private
+
+ def help_message(trigger, text)
+ return "No commands available :thinking_face:" unless @resource.present?
+
+ if text.start_with?('help')
+ header_with_list("Available commands", full_commands(trigger))
+ else
+ header_with_list("Unknown command, these commands are available", full_commands(trigger))
+ end
+ end
+
+ def full_commands(trigger)
+ @resource.map { |command| "#{trigger} #{command.help_message}" }
+ end
+ end
+ end
+ end
+end