2017-01-19 08:22:09 +00:00
|
|
|
module Gitlab
|
|
|
|
module ChatCommands
|
|
|
|
module Presenters
|
|
|
|
class Help < Presenters::Base
|
2017-01-30 11:12:57 +00:00
|
|
|
def present(trigger, text)
|
|
|
|
ephemeral_response(text: help_message(trigger, text))
|
2017-01-11 14:04:49 +00:00
|
|
|
end
|
|
|
|
|
2017-01-19 08:22:09 +00:00
|
|
|
private
|
2017-01-11 14:04:49 +00:00
|
|
|
|
2017-01-30 11:12:57 +00:00
|
|
|
def help_message(trigger, text)
|
|
|
|
return "No commands available :thinking_face:" unless @resource.present?
|
|
|
|
|
|
|
|
if text.start_with?('help')
|
2017-01-19 08:22:09 +00:00
|
|
|
header_with_list("Available commands", full_commands(trigger))
|
2017-01-26 14:30:34 +00:00
|
|
|
else
|
2017-01-30 11:12:57 +00:00
|
|
|
header_with_list("Unknown command, these commands are available", full_commands(trigger))
|
2017-01-19 08:22:09 +00:00
|
|
|
end
|
|
|
|
end
|
2017-01-11 14:04:49 +00:00
|
|
|
|
2017-01-19 08:22:09 +00:00
|
|
|
def full_commands(trigger)
|
|
|
|
@resource.map { |command| "#{trigger} #{command.help_message}" }
|
|
|
|
end
|
|
|
|
end
|
2017-01-11 14:04:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|