Module: Tr3llo::Command::Label

Extended by:
Label
Included in:
Label
Defined in:
lib/3llo/command/label.rb,
lib/3llo/command/label/add.rb,
lib/3llo/command/label/edit.rb,
lib/3llo/command/label/list.rb,
lib/3llo/command/label/remove.rb,
lib/3llo/command/label/invalid.rb

Defined Under Namespace

Modules: Add, Edit, Invalid, List, Remove

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
# File 'lib/3llo/command/label.rb', line 8

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

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

    Command::Label::Add.execute(board[:id])
  when "edit"
    label_key, = args
    Utils.assert_string!(label_key, "label key is missing")

    Command::Label::Edit.execute(label_key)
  when "remove"
    label_key, = args
    Utils.assert_string!(label_key, "label key is missing")

    Command::Label::Remove.execute(label_key)
  else
    handle_invalid_subcommand(subcommand, args)
  end
rescue InvalidArgumentError, InvalidCommandError, BoardNotSelectedError => exception
  Command::Label::Invalid.execute(exception.message)
end