Module: Tr3llo::Command

Extended by:
Command
Included in:
Command
Defined in:
lib/3llo/command.rb,
lib/3llo/command/card.rb,
lib/3llo/command/exit.rb,
lib/3llo/command/help.rb,
lib/3llo/command/list.rb,
lib/3llo/command/board.rb,
lib/3llo/command/label.rb,
lib/3llo/command/invalid.rb,
lib/3llo/command/card/add.rb,
lib/3llo/command/list/add.rb,
lib/3llo/command/board/add.rb,
lib/3llo/command/card/edit.rb,
lib/3llo/command/card/list.rb,
lib/3llo/command/card/move.rb,
lib/3llo/command/card/show.rb,
lib/3llo/command/label/add.rb,
lib/3llo/command/list/list.rb,
lib/3llo/command/board/list.rb,
lib/3llo/command/label/edit.rb,
lib/3llo/command/label/list.rb,
lib/3llo/command/list/cards.rb,
lib/3llo/command/card/assign.rb,
lib/3llo/command/board/select.rb,
lib/3llo/command/card/archive.rb,
lib/3llo/command/card/comment.rb,
lib/3llo/command/card/invalid.rb,
lib/3llo/command/label/remove.rb,
lib/3llo/command/list/invalid.rb,
lib/3llo/command/board/invalid.rb,
lib/3llo/command/card/add_item.rb,
lib/3llo/command/card/comments.rb,
lib/3llo/command/label/invalid.rb,
lib/3llo/command/card/add_label.rb,
lib/3llo/command/card/edit_item.rb,
lib/3llo/command/card/list_mine.rb,
lib/3llo/command/card/check_item.rb,
lib/3llo/command/card/remove_item.rb,
lib/3llo/command/card/self_assign.rb,
lib/3llo/command/card/uncheck_item.rb,
lib/3llo/command/card/add_checklist.rb,
lib/3llo/command/list/archive_cards.rb,
lib/3llo/command/card/edit_checklist.rb,
lib/3llo/command/card/remove_checklist.rb

Defined Under Namespace

Modules: Board, Card, Exit, Help, Invalid, Label, List

Instance Method Summary collapse

Instance Method Details

#execute(command_buffer) ⇒ Object



13
14
15
# File 'lib/3llo/command.rb', line 13

def execute(command_buffer)
  build_command(command_buffer)
end

#generate_suggestions(buffer, command_buffer) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/3llo/command.rb', line 17

def generate_suggestions(buffer, command_buffer)
  commands = {
    "board" => %w[add list select],
    "list" => %w[list add cards archive-cards],
    "card" => %w[
      list show add edit archive list-mine move
      comment comments self-assign assign
      add-checklist edit-checklist remove-checklist
      add-item edit-item remote-item check-item uncheck-item add-label
    ],
    "label" => %w[list add edit remove],
    "help" => [],
    "exit" => []
  }

  command, _subcommand, _args = parse_command(command_buffer)

  if commands.has_key?(command)
    subcommands = commands.fetch(command)

    subcommands
      .grep(/^#{Regexp.escape(buffer)}/)
      .reject { |suggestion| suggestion == buffer }
  else
    commands.keys.grep(/^#{Regexp.escape(buffer)}/)
  end
end