Module: Tr3llo::Command::List

Extended by:
List
Included in:
List
Defined in:
lib/3llo/command/list.rb,
lib/3llo/command/list/add.rb,
lib/3llo/command/list/list.rb,
lib/3llo/command/list/cards.rb,
lib/3llo/command/list/invalid.rb,
lib/3llo/command/list/archive_cards.rb

Defined Under Namespace

Modules: Add, ArchiveCards, Cards, Invalid, List

Instance Method Summary collapse

Instance Method Details

#execute(subcommand, args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/3llo/command/list.rb', line 8

def execute(subcommand, args)
  case subcommand
  when "list"
    board = Application.fetch_board!()

    Command::List::List.execute(board[:id])
  when "add"
    board = Application.fetch_board!()

    Command::List::Add.execute(board[:id])
  when "cards"
    list_key, = args
    Utils.assert_string!(list_key, "list key is missing")

    Command::List::Cards.execute(list_key)
  when "archive-cards"
    list_key, = args
    Utils.assert_string!(list_key, "list key is missing")

    Command::List::ArchiveCards.execute(list_key)
  else
    handle_invalid_subcommand(subcommand, args)
  end
rescue InvalidArgumentError => exception
  Command::List::Invalid.execute(exception.message)
rescue InvalidCommandError => exception
  Command::List::Invalid.execute(exception.message)
rescue BoardNotSelectedError => exception
  Command::List::Invalid.execute(exception.message)
end