3llo 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b821782c50c15268558fee17228bd87e7c1c013c65df510f293701f993f3048e
4
- data.tar.gz: 1a16571e8eef793329e113aedac17f66e077434ec9d06906e8949c7f57a46f46
3
+ metadata.gz: 924f5388e35597e1570a41cc0e0d346d999a6c5a354904e2d4db189579a5047d
4
+ data.tar.gz: 0d6d728e7831db53095118317a12e3d952793ecdae041db2dd75ca6d8282f515
5
5
  SHA512:
6
- metadata.gz: c93eccf148fa41d4ee1a5aa59cc847b63b4ed6b9a52b0b0ca584effbe403b02b5048df80df398272a23fe5b36e3d983bb2bfefa42c2972dc038281461b1225ed
7
- data.tar.gz: d1b1c3f133d46ff8f6588899efc9ea29e8db1cacedaf9a113c3384cacba2011cd8f7d7461b096124da592bab8558250c20ad691d358b794174356597cd24b176
6
+ metadata.gz: 11c88432c0490b325080423edee099ac78263f7f0efcb7ef0f9d81d5348733d26649bddfcb335452946b5b8150b2dc539fb224094f6efeabc128ee14694cc198
7
+ data.tar.gz: '0318a410ef4b35661a9442cab3cdf9a22dcec2cda1645e0000e6eab0629b38ea6df4c97183dae1beb814b444bbd05a841d7da4db1f86aea1882207466f91664d'
@@ -117,3 +117,6 @@ Style/StringLiteralsInInterpolation:
117
117
 
118
118
  Style/RaiseArgs:
119
119
  EnforcedStyle: compact
120
+
121
+ Lint/NonDeterministicRequireOrder:
122
+ Enabled: false
@@ -5,8 +5,8 @@ require "3llo/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "3llo"
7
7
  spec.version = Tr3llo::VERSION
8
- spec.authors = ["Cẩm Huỳnh"]
9
- spec.email = ["huynhquancam@gmail.com"]
8
+ spec.authors = ["Cẩm Huỳnh", "Diệp Sở Hùng"]
9
+ spec.email = ["huynhquancam@gmail.com", "diepsohung@gmail.com"]
10
10
 
11
11
  spec.summary = "Trello CLI app"
12
12
  spec.description = "Interactive CLI application for Trello"
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.2.0
4
+
5
+ * Support running multiple commands with `--init` switch (#83)
6
+ * Include current board name to status line (#77)
7
+ * Introduce `card add-label` command (#74)
8
+ * Support multiline card description (#72)
9
+
3
10
  ## v1.1.0
4
11
 
5
12
  * Introduce "list add" command.
data/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2020 Cẩm Huỳnh
3
+ Copyright (c) 2017 Cẩm Huỳnh
4
+ Copyright (c) 2020 Cẩm Huỳnh and Diệp Sở Hùng
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
@@ -3,7 +3,6 @@ require "3llo/remote_server"
3
3
  require "3llo/interface"
4
4
  require "container"
5
5
  require "json"
6
- require "erb"
7
6
 
8
7
  require "3llo/application"
9
8
  require "3llo/configuration"
@@ -116,6 +116,12 @@ module Tr3llo
116
116
  client.put(req_path, {}, payload)
117
117
  end
118
118
 
119
+ def add_labels(card_id, labels)
120
+ req_path = Utils.build_req_path("/cards/#{card_id}/idLabels")
121
+
122
+ client.put(req_path, {}, {"value" => labels.join(",")})
123
+ end
124
+
119
125
  private
120
126
 
121
127
  def make_struct(payload)
@@ -135,10 +141,11 @@ module Tr3llo
135
141
  payload
136
142
  .fetch("labels", [])
137
143
  .map do |label_payload|
144
+ label_id = label_payload.fetch("id")
138
145
  label_name = label_payload.fetch("name")
139
146
  label_color = label_payload["color"]
140
147
 
141
- Entities::Label.new(id: nil, shortcut: nil, name: label_name, color: label_color)
148
+ Entities::Label.new(id: label_id, shortcut: nil, name: label_name, color: label_color)
142
149
  end
143
150
 
144
151
  card =
@@ -22,7 +22,7 @@ module Tr3llo
22
22
  list show add edit archive list-mine move
23
23
  comment comments self-assign assign
24
24
  add-checklist edit-checklist remove-checklist
25
- add-item edit-item remote-item check-item uncheck-item
25
+ add-item edit-item remote-item check-item uncheck-item add-label
26
26
  ],
27
27
  "label" => %w[list add edit remove],
28
28
  "help" => [],
@@ -1,7 +1,4 @@
1
- require "3llo/command/board/list"
2
- require "3llo/command/board/select"
3
- require "3llo/command/board/invalid"
4
- require "3llo/command/board/add"
1
+ Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/board/*.rb")
5
2
 
6
3
  module Tr3llo
7
4
  module Command
@@ -1,23 +1,4 @@
1
- require "3llo/command/card/list"
2
- require "3llo/command/card/list_mine"
3
- require "3llo/command/card/edit"
4
- require "3llo/command/card/show"
5
- require "3llo/command/card/move"
6
- require "3llo/command/card/self_assign"
7
- require "3llo/command/card/assign"
8
- require "3llo/command/card/invalid"
9
- require "3llo/command/card/comments"
10
- require "3llo/command/card/comment"
11
- require "3llo/command/card/add"
12
- require "3llo/command/card/archive"
13
- require "3llo/command/card/add_checklist"
14
- require "3llo/command/card/edit_checklist"
15
- require "3llo/command/card/remove_checklist"
16
- require "3llo/command/card/add_item"
17
- require "3llo/command/card/check_item"
18
- require "3llo/command/card/uncheck_item"
19
- require "3llo/command/card/edit_item"
20
- require "3llo/command/card/remove_item"
1
+ Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/card/*.rb")
21
2
 
22
3
  module Tr3llo
23
4
  module Command
@@ -125,6 +106,12 @@ module Tr3llo
125
106
  Utils.assert_string!(check_item_key, "item key is missing")
126
107
 
127
108
  Command::Card::RemoveItem.execute(card_key, check_item_key)
109
+ when "add-label"
110
+ board = Application.fetch_board!()
111
+ card_key, = args
112
+ Utils.assert_string!(card_key, "card key is missing")
113
+
114
+ Command::Card::AddLabel.execute(card_key, board[:id])
128
115
  else
129
116
  handle_invalid_subcommand(subcommand, args)
130
117
  end
@@ -21,7 +21,7 @@ module Tr3llo
21
21
  )
22
22
 
23
23
  name = interface.input.ask("Name:", required: true)
24
- description = interface.input.ask("Description:")
24
+ description = interface.input.multiline("Description:").join("")
25
25
 
26
26
  API::Card.create(name, description, list_id)
27
27
 
@@ -0,0 +1,56 @@
1
+ module Tr3llo
2
+ module Command
3
+ module Card
4
+ module AddLabel
5
+ extend self
6
+
7
+ def execute(key, board_id)
8
+ card_id = Entities.parse_id(:card, key)
9
+ assert_card_id!(card_id, key)
10
+
11
+ card = API::Card.find(card_id)
12
+
13
+ interface = Application.fetch_interface!()
14
+
15
+ interface.print_frame do
16
+ label_ids = select_labels(interface, card, board_id)
17
+
18
+ add_labels(card_id, label_ids)
19
+ interface.puts("Chosen labels have been added to the card.")
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def assert_card_id!(card_id, key)
26
+ raise InvalidArgumentError.new("#{key.inspect} is not a valid card key") unless card_id
27
+ end
28
+
29
+ def add_labels(card_id, label_ids)
30
+ API::Card.add_labels(card_id, label_ids)
31
+ end
32
+
33
+ def select_labels(interface, card, board_id)
34
+ label_options =
35
+ API::Label.find_all_by_board(board_id)
36
+ .map { |label| [label.name, label.id] }
37
+ .to_h()
38
+
39
+ preselected_label_ids =
40
+ card.labels.flat_map do |label|
41
+ index = label_options.find_index { |_label_name, label_id| label_id == label.id }
42
+
43
+ index ? [index + 1] : []
44
+ end
45
+
46
+ interface.input.multi_select(
47
+ "Choose the labels to add to this card:",
48
+ label_options,
49
+ default: preselected_label_ids,
50
+ enum: "."
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -33,10 +33,6 @@ module Tr3llo
33
33
  )
34
34
  end
35
35
 
36
- def move_card!(card_id, list_id)
37
- API::Card.move_to_list(card_id, list_id)
38
- end
39
-
40
36
  def assert_card_id!(card_id, key)
41
37
  raise InvalidArgumentError.new("#{key.inspect} is not a valid card key") unless card_id
42
38
  end
@@ -1,8 +1,4 @@
1
- require "3llo/command/label/list"
2
- require "3llo/command/label/add"
3
- require "3llo/command/label/edit"
4
- require "3llo/command/label/remove"
5
- require "3llo/command/label/invalid"
1
+ Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/label/*.rb")
6
2
 
7
3
  module Tr3llo
8
4
  module Command
@@ -1,8 +1,4 @@
1
- require "3llo/command/list/list"
2
- require "3llo/command/list/add"
3
- require "3llo/command/list/cards"
4
- require "3llo/command/list/invalid"
5
- require "3llo/command/list/archive_cards"
1
+ Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/list/*.rb")
6
2
 
7
3
  module Tr3llo
8
4
  module Command
@@ -13,14 +13,16 @@ module Tr3llo
13
13
  interface = Application.fetch_interface!()
14
14
 
15
15
  if init_command && init_command != ""
16
- interface.puts("Executing " + Utils.format_highlight(init_command) + " command")
17
-
18
- execute_command!(init_command)
16
+ init_commands = init_command.split(";")
17
+ init_commands.each do |cmd|
18
+ interface.puts("Executing " + Utils.format_highlight(cmd) + " command")
19
+ execute_command!(cmd)
20
+ end
19
21
  end
20
22
 
21
23
  loop do
22
- command_buffer = Readline.readline("\e[15;48;5;27m 3llo \e[0m > ", true)
23
-
24
+ status_line = determine_status_line()
25
+ command_buffer = Readline.readline(status_line, true)
24
26
  Command::Exit.execute() if command_buffer.nil?
25
27
 
26
28
  execute_command!(command_buffer)
@@ -31,6 +33,18 @@ module Tr3llo
31
33
 
32
34
  private
33
35
 
36
+ def determine_status_line()
37
+ program_name = ["\e[15;48;5;27m 3llo \e[0m"]
38
+ board_name =
39
+ begin
40
+ ["\e[45m #{Application.fetch_board!().name} \e[0m"]
41
+ rescue BoardNotSelectedError
42
+ []
43
+ end
44
+
45
+ (program_name + board_name + [""]).join(" > ")
46
+ end
47
+
34
48
  def execute_command!(command_buffer)
35
49
  Tr3llo::Command.execute(command_buffer.strip())
36
50
  end
@@ -67,5 +67,11 @@ module Tr3llo
67
67
 
68
68
  [path, URI.encode_www_form(params)].join("?")
69
69
  end
70
+
71
+ def require_directory(glob)
72
+ Dir.glob(glob).each do |file|
73
+ require file
74
+ end
75
+ end
70
76
  end
71
77
  end
@@ -1,3 +1,3 @@
1
1
  module Tr3llo
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -18,6 +18,7 @@ module Tr3llo
18
18
  card comments <key> - Load recent comments of a card
19
19
  card comment <key> - Add a comment to a card
20
20
  card archive <key> - Archive a card
21
+ card add-label <key> - Label a card
21
22
 
22
23
  #{Utils.format_bold("# Available checklist commands:")}
23
24
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3llo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cẩm Huỳnh
8
- autorequire:
8
+ - Diệp Sở Hùng
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-04-18 00:00:00.000000000 Z
12
+ date: 2020-12-06 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: tty-prompt
@@ -55,6 +56,7 @@ dependencies:
55
56
  description: Interactive CLI application for Trello
56
57
  email:
57
58
  - huynhquancam@gmail.com
59
+ - diepsohung@gmail.com
58
60
  executables:
59
61
  - 3llo
60
62
  extensions: []
@@ -91,6 +93,7 @@ files:
91
93
  - lib/3llo/command/card/add.rb
92
94
  - lib/3llo/command/card/add_checklist.rb
93
95
  - lib/3llo/command/card/add_item.rb
96
+ - lib/3llo/command/card/add_label.rb
94
97
  - lib/3llo/command/card/archive.rb
95
98
  - lib/3llo/command/card/assign.rb
96
99
  - lib/3llo/command/card/check_item.rb
@@ -153,7 +156,7 @@ licenses:
153
156
  - MIT
154
157
  metadata:
155
158
  allowed_push_host: https://rubygems.org
156
- post_install_message:
159
+ post_install_message:
157
160
  rdoc_options: []
158
161
  require_paths:
159
162
  - lib
@@ -169,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  version: '0'
170
173
  requirements: []
171
174
  rubygems_version: 3.1.2
172
- signing_key:
175
+ signing_key:
173
176
  specification_version: 4
174
177
  summary: Trello CLI app
175
178
  test_files: []