summaryrefslogtreecommitdiff
path: root/lib/gitlab/chat_commands/presenters/help.rb
blob: 133b707231f40d14362c3d30de07ae632d7d8aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Gitlab::ChatCommands::Presenters
  class Help < Gitlab::ChatCommands::Presenters::Base
    def present(trigger)
      message =
        if @resource.none?
          "No commands available :thinking_face:"
        else
          header_with_list("Available commands", full_commands(trigger))
        end

      ephemeral_response(text: message)
    end

    private

    def full_commands(trigger)
      @resource.map { |command| "#{trigger} #{command.help_message}" }
    end
  end
end