Module: Tr3llo::Command::Label::Edit

Extended by:
Edit
Included in:
Edit
Defined in:
lib/3llo/command/label/edit.rb

Instance Method Summary collapse

Instance Method Details

#execute(label_key) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/3llo/command/label/edit.rb', line 7

def execute(label_key)
  label_id = Entities.parse_id(:label, label_key)
  assert_label_id!(label_id, label_key)

  label = API::Label.find(label_id)

  interface = Application.fetch_interface!()

  interface.print_frame do
    name = interface.input.ask("Name:", required: true, value: label.name)
    color = interface.input.select(
      "Choose the color:",
      Utils::TRELLO_LABEL_COLOR,
      default: Utils::TRELLO_LABEL_COLOR.index(label.color)
    )

    API::Label.update(label_id, {"name" => name, "color" => color})

    interface.puts("Label has been updated.")
  end
end