Module: Tr3llo::Command::Card

Extended by:
Card
Included in:
Card
Defined in:
lib/3llo/command/card.rb,
lib/3llo/command/card/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/card/assign.rb,
lib/3llo/command/card/archive.rb,
lib/3llo/command/card/comment.rb,
lib/3llo/command/card/invalid.rb,
lib/3llo/command/card/add_item.rb,
lib/3llo/command/card/comments.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/card/edit_checklist.rb,
lib/3llo/command/card/remove_checklist.rb

Defined Under Namespace

Modules: Add, AddChecklist, AddItem, AddLabel, Archive, Assign, CheckItem, Comment, Comments, Edit, EditChecklist, EditItem, Invalid, List, ListMine, Move, RemoveChecklist, RemoveItem, SelfAssign, Show, UncheckItem

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/3llo/command/card.rb', line 8

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

    Command::Card::List.execute(board.id)
  when "list-mine"
    board = Application.fetch_board!()
    user = Application.fetch_user!()

    Command::Card::ListMine.execute(board.id, user.id)
  when "add"
    board = Application.fetch_board!()
    Command::Card::Add.execute(board[:id])
  when "show"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Show.execute(card_key)
  when "edit"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Edit.execute(card_key)
  when "comments"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Comments.execute(card_key)
  when "comment"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Comment.execute(card_key)
  when "move"
    board = Application.fetch_board!()
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Move.execute(card_key, board[:id])
  when "self-assign"
    user = Application.fetch_user!()
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::SelfAssign.execute(card_key, user[:id])
  when "assign"
    board = Application.fetch_board!()
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Assign.execute(card_key, board[:id])
  when "archive"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::Archive.execute(card_key)
  when "add-checklist"
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::AddChecklist.execute(card_key)
  when "edit-checklist"
    checklist_key, = args
    Utils.assert_string!(checklist_key, "checklist key is missing")

    Command::Card::EditChecklist.execute(checklist_key)
  when "remove-checklist"
    checklist_key, = args
    Utils.assert_string!(checklist_key, "checklist key is missing")

    Command::Card::RemoveChecklist.execute(checklist_key)
  when "add-item"
    checklist_key, = args
    Utils.assert_string!(checklist_key, "checklist key is missing")

    Command::Card::AddItem.execute(checklist_key)
  when "check-item"
    card_key, check_item_key, = args
    Utils.assert_string!(card_key, "card key is missing")
    Utils.assert_string!(check_item_key, "item key is missing")

    Command::Card::CheckItem.execute(card_key, check_item_key)
  when "uncheck-item"
    card_key, check_item_key, = args
    Utils.assert_string!(card_key, "card key is missing")
    Utils.assert_string!(check_item_key, "item key is missing")

    Command::Card::UncheckItem.execute(card_key, check_item_key)
  when "edit-item"
    card_key, check_item_key, = args
    Utils.assert_string!(card_key, "card key is missing")
    Utils.assert_string!(check_item_key, "item key is missing")

    Command::Card::EditItem.execute(card_key, check_item_key)
  when "remove-item"
    card_key, check_item_key, = args
    Utils.assert_string!(card_key, "card key is missing")
    Utils.assert_string!(check_item_key, "item key is missing")

    Command::Card::RemoveItem.execute(card_key, check_item_key)
  when "add-label"
    board = Application.fetch_board!()
    card_key, = args
    Utils.assert_string!(card_key, "card key is missing")

    Command::Card::AddLabel.execute(card_key, board[:id])
  else
    handle_invalid_subcommand(subcommand, args)
  end
rescue InvalidArgumentError => exception
  Command::Card::Invalid.execute(exception.message)
rescue InvalidCommandError => exception
  Command::Card::Invalid.execute(exception.message)
rescue BoardNotSelectedError => exception
  Command::Card::Invalid.execute(exception.message)
end