3llo 1.0.0 → 1.3.1
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 +4 -4
- data/.rubocop.yml +11 -2
- data/3llo.gemspec +3 -3
- data/CHANGELOG.md +23 -0
- data/LICENSE +2 -1
- data/Rakefile +3 -9
- data/lib/3llo/api/board.rb +12 -0
- data/lib/3llo/api/card.rb +8 -1
- data/lib/3llo/api/label.rb +64 -0
- data/lib/3llo/api/list.rb +10 -0
- data/lib/3llo/api.rb +1 -0
- data/lib/3llo/command/board/add.rb +29 -0
- data/lib/3llo/command/board.rb +4 -6
- data/lib/3llo/command/card/add.rb +12 -8
- data/lib/3llo/command/card/add_label.rb +56 -0
- data/lib/3llo/command/card/move.rb +0 -4
- data/lib/3llo/command/card.rb +7 -20
- data/lib/3llo/command/label/add.rb +22 -0
- data/lib/3llo/command/label/edit.rb +37 -0
- data/lib/3llo/command/label/invalid.rb +18 -0
- data/lib/3llo/command/label/list.rb +18 -0
- data/lib/3llo/command/label/remove.rb +28 -0
- data/lib/3llo/command/label.rb +47 -0
- data/lib/3llo/command/list/add.rb +21 -0
- data/lib/3llo/command/list.rb +5 -4
- data/lib/3llo/command.rb +7 -3
- data/lib/3llo/controller.rb +21 -5
- data/lib/3llo/entities.rb +1 -1
- data/lib/3llo/remote_server.rb +2 -0
- data/lib/3llo/utils.rb +8 -0
- data/lib/3llo/version.rb +1 -1
- data/lib/3llo/view/board/help.rb +1 -0
- data/lib/3llo/view/card/help.rb +1 -0
- data/lib/3llo/view/help.rb +2 -0
- data/lib/3llo/view/label/help.rb +20 -0
- data/lib/3llo/view/label/list.rb +21 -0
- data/lib/3llo/view/list/help.rb +1 -0
- data/lib/3llo/view.rb +2 -0
- data/lib/3llo.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1461854cddc2b1c620478538b38f7500d885d935c22921cd90e249359e492e
|
4
|
+
data.tar.gz: 757aea8fd3cd7bd43394f5d4ca32f34695008252e23d48bf9b523535d3093247
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c970411655be89226255b61ef97f69d9d12067c3eae1dbda1f227868be53c0d2977f2d1c4e630a0d6aa944c94deb9fa8c86a2a681e62b2c48cfa7bf4710a1dbc
|
7
|
+
data.tar.gz: 8a53b15db5b4209400bc85141522a2d0afc2fe2702d4c0187b8856ca3f3d6ffbe2c88c6e906d78be55f562b0b31f729a3737b3ca1bbe63aa57194ce9eddd2216
|
data/.rubocop.yml
CHANGED
@@ -57,8 +57,14 @@ Security/JSONLoad:
|
|
57
57
|
Style/Alias:
|
58
58
|
EnforcedStyle: prefer_alias
|
59
59
|
|
60
|
-
Style/
|
61
|
-
Enabled:
|
60
|
+
Style/HashEachMethods:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Style/HashTransformKeys:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Style/HashTransformValues:
|
67
|
+
Enabled: true
|
62
68
|
|
63
69
|
Style/DefWithParentheses:
|
64
70
|
Enabled: false
|
@@ -111,3 +117,6 @@ Style/StringLiteralsInInterpolation:
|
|
111
117
|
|
112
118
|
Style/RaiseArgs:
|
113
119
|
EnforcedStyle: compact
|
120
|
+
|
121
|
+
Lint/NonDeterministicRequireOrder:
|
122
|
+
Enabled: false
|
data/3llo.gemspec
CHANGED
@@ -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"
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^bin/}) { |filename| File.basename(filename) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.required_ruby_version = "~>
|
27
|
+
spec.required_ruby_version = "~> 3.0"
|
28
28
|
|
29
29
|
spec.add_runtime_dependency "tty-prompt", "~> 0.20"
|
30
30
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v1.3.1
|
4
|
+
|
5
|
+
* Require Ruby version 3
|
6
|
+
|
7
|
+
## v1.3.0 (yanked)
|
8
|
+
|
9
|
+
* Support Ruby version 3
|
10
|
+
* Fix comment listing (#86)
|
11
|
+
|
12
|
+
## v1.2.0
|
13
|
+
|
14
|
+
* Support running multiple commands with `--init` switch (#83)
|
15
|
+
* Include current board name to status line (#77)
|
16
|
+
* Introduce `card add-label` command (#74)
|
17
|
+
* Support multiline card description (#72)
|
18
|
+
|
19
|
+
## v1.1.0
|
20
|
+
|
21
|
+
* Introduce "list add" command.
|
22
|
+
* Introduce "board add" command.
|
23
|
+
* Introduce label related command.
|
24
|
+
* Support exiting with Ctrl+D.
|
25
|
+
|
3
26
|
## v1.0.0
|
4
27
|
|
5
28
|
* Support using shortcuts to access entities.
|
data/LICENSE
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017
|
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
|
data/Rakefile
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
|
1
|
+
require "rspec/core/rake_task"
|
2
|
+
RSpec::Core::RakeTask.new(:spec)
|
3
3
|
|
4
|
-
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
-
end
|
9
|
-
|
10
|
-
task default: :test
|
4
|
+
task default: :spec
|
data/lib/3llo/api/board.rb
CHANGED
@@ -25,6 +25,18 @@ module Tr3llo
|
|
25
25
|
make_struct(client.get(req_path, {}))
|
26
26
|
end
|
27
27
|
|
28
|
+
def create(name:, desc:, default_lists: true)
|
29
|
+
client = Application.fetch_client!()
|
30
|
+
req_path = Utils.build_req_path("/boards", {})
|
31
|
+
payload = {
|
32
|
+
"name" => name,
|
33
|
+
"desc" => desc,
|
34
|
+
"defaultLists" => default_lists
|
35
|
+
}
|
36
|
+
|
37
|
+
client.post(req_path, {}, payload)
|
38
|
+
end
|
39
|
+
|
28
40
|
private
|
29
41
|
|
30
42
|
def make_struct(payload)
|
data/lib/3llo/api/card.rb
CHANGED
@@ -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(label_name, 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 =
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module API
|
3
|
+
module Label
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def find_all_by_board(board_id)
|
7
|
+
req_path =
|
8
|
+
Utils.build_req_path(
|
9
|
+
"/boards/#{board_id}/labels"
|
10
|
+
)
|
11
|
+
|
12
|
+
client
|
13
|
+
.get(req_path, {})
|
14
|
+
.reject { |label| label["name"].empty? }
|
15
|
+
.map do |label_payload|
|
16
|
+
make_struct(label_payload)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def find(label_id)
|
21
|
+
req_path = Utils.build_req_path("/labels/#{label_id}")
|
22
|
+
label_payload = client.get(req_path, {})
|
23
|
+
|
24
|
+
make_struct(label_payload)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(name:, color:, board_id:)
|
28
|
+
req_path = Utils.build_req_path("/labels")
|
29
|
+
payload = {
|
30
|
+
"name" => name,
|
31
|
+
"color" => color,
|
32
|
+
"idBoard" => board_id
|
33
|
+
}
|
34
|
+
|
35
|
+
client.post(req_path, {}, payload)
|
36
|
+
end
|
37
|
+
|
38
|
+
def update(label_id, data)
|
39
|
+
req_path = Utils.build_req_path("/labels/#{label_id}")
|
40
|
+
|
41
|
+
client.put(req_path, {}, data)
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete(label_id)
|
45
|
+
req_path = Utils.build_req_path("/labels/#{label_id}")
|
46
|
+
|
47
|
+
client.delete(req_path, {}, {})
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def make_struct(payload)
|
53
|
+
id, name, color = payload.fetch_values("id", "name", "color")
|
54
|
+
shortcut = Entities.make_shortcut(:label, id)
|
55
|
+
|
56
|
+
Entities::Label.new(id: id, shortcut: shortcut, name: name, color: color)
|
57
|
+
end
|
58
|
+
|
59
|
+
def client
|
60
|
+
Application.fetch_client!()
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/3llo/api/list.rb
CHANGED
@@ -23,6 +23,16 @@ module Tr3llo
|
|
23
23
|
client.post(req_path, {}, {})
|
24
24
|
end
|
25
25
|
|
26
|
+
def create(name, board_id)
|
27
|
+
req_path = Utils.build_req_path("/lists")
|
28
|
+
payload = {
|
29
|
+
"name" => name,
|
30
|
+
"idBoard" => board_id
|
31
|
+
}
|
32
|
+
|
33
|
+
client.post(req_path, {}, payload)
|
34
|
+
end
|
35
|
+
|
26
36
|
private
|
27
37
|
|
28
38
|
def make_struct(payload)
|
data/lib/3llo/api.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Board
|
4
|
+
module Add
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute()
|
8
|
+
interface = Application.fetch_interface!()
|
9
|
+
|
10
|
+
interface.print_frame do
|
11
|
+
name = interface.input.ask("Name:", required: true)
|
12
|
+
desc = interface.input.ask("Description:")
|
13
|
+
|
14
|
+
default_lists =
|
15
|
+
interface.input.yes?("With default set of lists to the board (To Do, Doing, Done)?") do |question|
|
16
|
+
question.default false
|
17
|
+
question.positive "Y"
|
18
|
+
question.negative "N"
|
19
|
+
end
|
20
|
+
|
21
|
+
API::Board.create(name: name, desc: desc, default_lists: default_lists)
|
22
|
+
|
23
|
+
interface.puts("Board has been created.")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/3llo/command/board.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require "3llo/command/board/select"
|
3
|
-
require "3llo/command/board/invalid"
|
1
|
+
Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/board/*.rb")
|
4
2
|
|
5
3
|
module Tr3llo
|
6
4
|
module Command
|
@@ -18,12 +16,12 @@ module Tr3llo
|
|
18
16
|
Utils.assert_string!(board_key, "board key is missing")
|
19
17
|
|
20
18
|
Command::Board::Select.execute(board_key)
|
19
|
+
when "add"
|
20
|
+
Command::Board::Add.execute()
|
21
21
|
else
|
22
22
|
handle_invalid_subcommand(subcommand, args)
|
23
23
|
end
|
24
|
-
rescue InvalidCommandError => exception
|
25
|
-
Command::Board::Invalid.execute(exception.message)
|
26
|
-
rescue InvalidArgumentError => exception
|
24
|
+
rescue InvalidCommandError, InvalidArgumentError => exception
|
27
25
|
Command::Board::Invalid.execute(exception.message)
|
28
26
|
end
|
29
27
|
|
@@ -14,17 +14,21 @@ module Tr3llo
|
|
14
14
|
interface = Application.fetch_interface!()
|
15
15
|
|
16
16
|
interface.print_frame do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if list_options.any?
|
18
|
+
list_id = interface.input.select(
|
19
|
+
"Choose the list this card should belong to:",
|
20
|
+
list_options
|
21
|
+
)
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
name = interface.input.ask("Name:", required: true)
|
24
|
+
description = interface.input.multiline("Description:").join("")
|
24
25
|
|
25
|
-
|
26
|
+
API::Card.create(name, description, list_id)
|
26
27
|
|
27
|
-
|
28
|
+
interface.puts("Card has been created.")
|
29
|
+
else
|
30
|
+
interface.puts("There is no list on board.")
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
@@ -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
|
data/lib/3llo/command/card.rb
CHANGED
@@ -1,23 +1,4 @@
|
|
1
|
-
|
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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Label
|
4
|
+
module Add
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(board_id)
|
8
|
+
interface = Application.fetch_interface!()
|
9
|
+
|
10
|
+
interface.print_frame do
|
11
|
+
name = interface.input.ask("Name:", required: true)
|
12
|
+
color = interface.input.select("Choose the color:", Utils::TRELLO_LABEL_COLOR)
|
13
|
+
|
14
|
+
API::Label.create(name: name, color: color, board_id: board_id)
|
15
|
+
|
16
|
+
interface.puts("Label has been created.")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Label
|
4
|
+
module Edit
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(label_key)
|
8
|
+
label_id = Entities.parse_id(:label, label_key)
|
9
|
+
assert_label_id!(label_id, label_key)
|
10
|
+
|
11
|
+
label = API::Label.find(label_id)
|
12
|
+
|
13
|
+
interface = Application.fetch_interface!()
|
14
|
+
|
15
|
+
interface.print_frame do
|
16
|
+
name = interface.input.ask("Name:", required: true, value: label.name)
|
17
|
+
color = interface.input.select(
|
18
|
+
"Choose the color:",
|
19
|
+
Utils::TRELLO_LABEL_COLOR,
|
20
|
+
default: Utils::TRELLO_LABEL_COLOR.index(label.color)
|
21
|
+
)
|
22
|
+
|
23
|
+
API::Label.update(label_id, {"name" => name, "color" => color})
|
24
|
+
|
25
|
+
interface.puts("Label has been updated.")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def assert_label_id!(label_id, key)
|
32
|
+
raise InvalidArgumentError.new("#{key.inspect} is not a valid label key") unless label_id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Label
|
4
|
+
module Invalid
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(message)
|
8
|
+
interface = Application.fetch_interface!()
|
9
|
+
|
10
|
+
interface.print_frame do
|
11
|
+
interface.print_error(message)
|
12
|
+
interface.puts(View::Label::Help.render())
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Label
|
4
|
+
module List
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(board_id)
|
8
|
+
interface = Application.fetch_interface!()
|
9
|
+
labels = API::Label.find_all_by_board(board_id)
|
10
|
+
|
11
|
+
interface.print_frame do
|
12
|
+
interface.puts(View::Label::List.render(labels))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module Label
|
4
|
+
module Remove
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(label_key)
|
8
|
+
label_id = Entities.parse_id(:label, label_key)
|
9
|
+
assert_label_id!(label_id, label_key)
|
10
|
+
|
11
|
+
interface = Application.fetch_interface!()
|
12
|
+
|
13
|
+
interface.print_frame do
|
14
|
+
API::Label.delete(label_id)
|
15
|
+
|
16
|
+
interface.puts("Label has been deleted.")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def assert_label_id!(label_id, key)
|
23
|
+
raise InvalidArgumentError.new("#{key.inspect} is not a valid label key") unless label_id
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/label/*.rb")
|
2
|
+
|
3
|
+
module Tr3llo
|
4
|
+
module Command
|
5
|
+
module Label
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def execute(subcommand, args)
|
9
|
+
case subcommand
|
10
|
+
when "list"
|
11
|
+
board = Application.fetch_board!()
|
12
|
+
|
13
|
+
Command::Label::List.execute(board[:id])
|
14
|
+
when "add"
|
15
|
+
board = Application.fetch_board!()
|
16
|
+
|
17
|
+
Command::Label::Add.execute(board[:id])
|
18
|
+
when "edit"
|
19
|
+
label_key, = args
|
20
|
+
Utils.assert_string!(label_key, "label key is missing")
|
21
|
+
|
22
|
+
Command::Label::Edit.execute(label_key)
|
23
|
+
when "remove"
|
24
|
+
label_key, = args
|
25
|
+
Utils.assert_string!(label_key, "label key is missing")
|
26
|
+
|
27
|
+
Command::Label::Remove.execute(label_key)
|
28
|
+
else
|
29
|
+
handle_invalid_subcommand(subcommand, args)
|
30
|
+
end
|
31
|
+
rescue InvalidArgumentError, InvalidCommandError, BoardNotSelectedError => exception
|
32
|
+
Command::Label::Invalid.execute(exception.message)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def handle_invalid_subcommand(subcommand, _args)
|
38
|
+
case subcommand
|
39
|
+
when String
|
40
|
+
raise InvalidCommandError.new("#{subcommand.inspect} is not a valid command")
|
41
|
+
when NilClass
|
42
|
+
raise InvalidCommandError.new("command is missing")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module Command
|
3
|
+
module List
|
4
|
+
module Add
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def execute(board_id)
|
8
|
+
interface = Application.fetch_interface!()
|
9
|
+
|
10
|
+
interface.print_frame do
|
11
|
+
name = interface.input.ask("Name:", required: true)
|
12
|
+
|
13
|
+
API::List.create(name, board_id)
|
14
|
+
|
15
|
+
interface.puts("List has been created.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/3llo/command/list.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
require "3llo/command/list/cards"
|
3
|
-
require "3llo/command/list/invalid"
|
4
|
-
require "3llo/command/list/archive_cards"
|
1
|
+
Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/list/*.rb")
|
5
2
|
|
6
3
|
module Tr3llo
|
7
4
|
module Command
|
@@ -14,6 +11,10 @@ module Tr3llo
|
|
14
11
|
board = Application.fetch_board!()
|
15
12
|
|
16
13
|
Command::List::List.execute(board[:id])
|
14
|
+
when "add"
|
15
|
+
board = Application.fetch_board!()
|
16
|
+
|
17
|
+
Command::List::Add.execute(board[:id])
|
17
18
|
when "cards"
|
18
19
|
list_key, = args
|
19
20
|
Utils.assert_string!(list_key, "list key is missing")
|
data/lib/3llo/command.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "3llo/command/board"
|
2
2
|
require "3llo/command/card"
|
3
3
|
require "3llo/command/list"
|
4
|
+
require "3llo/command/label"
|
4
5
|
require "3llo/command/help"
|
5
6
|
require "3llo/command/exit"
|
6
7
|
require "3llo/command/invalid"
|
@@ -15,14 +16,15 @@ module Tr3llo
|
|
15
16
|
|
16
17
|
def generate_suggestions(buffer, command_buffer)
|
17
18
|
commands = {
|
18
|
-
"board" => [
|
19
|
-
"list" => %w[list cards archive-cards],
|
19
|
+
"board" => %w[add list select],
|
20
|
+
"list" => %w[list add cards archive-cards],
|
20
21
|
"card" => %w[
|
21
22
|
list show add edit archive list-mine move
|
22
23
|
comment comments self-assign assign
|
23
24
|
add-checklist edit-checklist remove-checklist
|
24
|
-
add-item edit-item remote-item check-item uncheck-item
|
25
|
+
add-item edit-item remote-item check-item uncheck-item add-label
|
25
26
|
],
|
27
|
+
"label" => %w[list add edit remove],
|
26
28
|
"help" => [],
|
27
29
|
"exit" => []
|
28
30
|
}
|
@@ -52,6 +54,8 @@ module Tr3llo
|
|
52
54
|
Command::Card.execute(subcommand, args)
|
53
55
|
when "list"
|
54
56
|
Command::List.execute(subcommand, args)
|
57
|
+
when "label"
|
58
|
+
Command::Label.execute(subcommand, args)
|
55
59
|
when "help"
|
56
60
|
Command::Help.execute()
|
57
61
|
when "exit"
|
data/lib/3llo/controller.rb
CHANGED
@@ -5,7 +5,7 @@ module Tr3llo
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def start(init_command)
|
8
|
-
Readline.completion_append_character = "
|
8
|
+
Readline.completion_append_character = " "
|
9
9
|
Readline.completion_proc = lambda { |buffer|
|
10
10
|
Command.generate_suggestions(buffer, Readline.line_buffer)
|
11
11
|
}
|
@@ -13,13 +13,17 @@ module Tr3llo
|
|
13
13
|
interface = Application.fetch_interface!()
|
14
14
|
|
15
15
|
if init_command && init_command != ""
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
24
|
+
status_line = determine_status_line()
|
25
|
+
command_buffer = Readline.readline(status_line, true)
|
26
|
+
Command::Exit.execute() if command_buffer.nil?
|
23
27
|
|
24
28
|
execute_command!(command_buffer)
|
25
29
|
end
|
@@ -29,6 +33,18 @@ module Tr3llo
|
|
29
33
|
|
30
34
|
private
|
31
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
|
+
|
32
48
|
def execute_command!(command_buffer)
|
33
49
|
Tr3llo::Command.execute(command_buffer.strip())
|
34
50
|
end
|
data/lib/3llo/entities.rb
CHANGED
@@ -11,7 +11,7 @@ module Tr3llo
|
|
11
11
|
Board = Struct.new(:id, :shortcut, :name)
|
12
12
|
List = Struct.new(:id, :shortcut, :name)
|
13
13
|
Card = Struct.new(:id, :shortcut, :name, :description, :short_url, :labels, :members, :list, keyword_init: true)
|
14
|
-
Label = Struct.new(:name, :color)
|
14
|
+
Label = Struct.new(:id, :shortcut, :name, :color, keyword_init: true)
|
15
15
|
Comment = Struct.new(:id, :text, :creator, :created_at, keyword_init: true)
|
16
16
|
Checklist = Struct.new(:id, :shortcut, :name, :items, keyword_init: true)
|
17
17
|
Checklist::Item = Struct.new(:id, :shortcut, :name, :state, keyword_init: true)
|
data/lib/3llo/remote_server.rb
CHANGED
data/lib/3llo/utils.rb
CHANGED
@@ -17,6 +17,8 @@ module Tr3llo
|
|
17
17
|
"sky" => 36
|
18
18
|
}.freeze()
|
19
19
|
|
20
|
+
TRELLO_LABEL_COLOR = %w[red pink blue green purple yellow orange sky].freeze()
|
21
|
+
|
20
22
|
def format_key_tag(id, shortcut)
|
21
23
|
formatted_shortcut = Utils.format_highlight(Entities::SHORTCUT_PREFIX + shortcut)
|
22
24
|
formatted_id = Utils.paint(id, "blue")
|
@@ -65,5 +67,11 @@ module Tr3llo
|
|
65
67
|
|
66
68
|
[path, URI.encode_www_form(params)].join("?")
|
67
69
|
end
|
70
|
+
|
71
|
+
def require_directory(glob)
|
72
|
+
Dir.glob(glob).each do |file|
|
73
|
+
require file
|
74
|
+
end
|
75
|
+
end
|
68
76
|
end
|
69
77
|
end
|
data/lib/3llo/version.rb
CHANGED
data/lib/3llo/view/board/help.rb
CHANGED
data/lib/3llo/view/card/help.rb
CHANGED
data/lib/3llo/view/help.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module View
|
3
|
+
module Label
|
4
|
+
module Help
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def render()
|
8
|
+
<<~TEMPLATE.strip
|
9
|
+
#{Utils.format_bold("# Available label commands:")}
|
10
|
+
|
11
|
+
label list - Show all labels
|
12
|
+
label add - Create a label
|
13
|
+
label edit <key> - Edit a label
|
14
|
+
list remove <key> - Remove a label
|
15
|
+
TEMPLATE
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Tr3llo
|
2
|
+
module View
|
3
|
+
module Label
|
4
|
+
module List
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def render(labels)
|
8
|
+
labels
|
9
|
+
.map { |label| render_label(label) }
|
10
|
+
.join("\n")
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def render_label(label)
|
16
|
+
"#{Utils.format_key_tag(label.id, label.shortcut)} #{Utils.paint("#" + label.name, label.color)}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/3llo/view/list/help.rb
CHANGED
data/lib/3llo/view.rb
CHANGED
data/lib/3llo.rb
CHANGED
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.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cẩm Huỳnh
|
8
|
-
|
8
|
+
- Diệp Sở Hùng
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-01-10 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: []
|
@@ -75,6 +77,7 @@ files:
|
|
75
77
|
- lib/3llo/api/board.rb
|
76
78
|
- lib/3llo/api/card.rb
|
77
79
|
- lib/3llo/api/checklist.rb
|
80
|
+
- lib/3llo/api/label.rb
|
78
81
|
- lib/3llo/api/list.rb
|
79
82
|
- lib/3llo/api/token.rb
|
80
83
|
- lib/3llo/api/user.rb
|
@@ -82,6 +85,7 @@ files:
|
|
82
85
|
- lib/3llo/command.rb
|
83
86
|
- lib/3llo/command/.gitkeep
|
84
87
|
- lib/3llo/command/board.rb
|
88
|
+
- lib/3llo/command/board/add.rb
|
85
89
|
- lib/3llo/command/board/invalid.rb
|
86
90
|
- lib/3llo/command/board/list.rb
|
87
91
|
- lib/3llo/command/board/select.rb
|
@@ -89,6 +93,7 @@ files:
|
|
89
93
|
- lib/3llo/command/card/add.rb
|
90
94
|
- lib/3llo/command/card/add_checklist.rb
|
91
95
|
- lib/3llo/command/card/add_item.rb
|
96
|
+
- lib/3llo/command/card/add_label.rb
|
92
97
|
- lib/3llo/command/card/archive.rb
|
93
98
|
- lib/3llo/command/card/assign.rb
|
94
99
|
- lib/3llo/command/card/check_item.rb
|
@@ -109,7 +114,14 @@ files:
|
|
109
114
|
- lib/3llo/command/exit.rb
|
110
115
|
- lib/3llo/command/help.rb
|
111
116
|
- lib/3llo/command/invalid.rb
|
117
|
+
- lib/3llo/command/label.rb
|
118
|
+
- lib/3llo/command/label/add.rb
|
119
|
+
- lib/3llo/command/label/edit.rb
|
120
|
+
- lib/3llo/command/label/invalid.rb
|
121
|
+
- lib/3llo/command/label/list.rb
|
122
|
+
- lib/3llo/command/label/remove.rb
|
112
123
|
- lib/3llo/command/list.rb
|
124
|
+
- lib/3llo/command/list/add.rb
|
113
125
|
- lib/3llo/command/list/archive_cards.rb
|
114
126
|
- lib/3llo/command/list/cards.rb
|
115
127
|
- lib/3llo/command/list/invalid.rb
|
@@ -133,6 +145,8 @@ files:
|
|
133
145
|
- lib/3llo/view/card/list_mine.rb
|
134
146
|
- lib/3llo/view/card/show.rb
|
135
147
|
- lib/3llo/view/help.rb
|
148
|
+
- lib/3llo/view/label/help.rb
|
149
|
+
- lib/3llo/view/label/list.rb
|
136
150
|
- lib/3llo/view/list/cards.rb
|
137
151
|
- lib/3llo/view/list/help.rb
|
138
152
|
- lib/3llo/view/list/list.rb
|
@@ -142,7 +156,7 @@ licenses:
|
|
142
156
|
- MIT
|
143
157
|
metadata:
|
144
158
|
allowed_push_host: https://rubygems.org
|
145
|
-
post_install_message:
|
159
|
+
post_install_message:
|
146
160
|
rdoc_options: []
|
147
161
|
require_paths:
|
148
162
|
- lib
|
@@ -150,15 +164,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
164
|
requirements:
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
167
|
+
version: '3.0'
|
154
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
170
|
- - ">="
|
157
171
|
- !ruby/object:Gem::Version
|
158
172
|
version: '0'
|
159
173
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
-
signing_key:
|
174
|
+
rubygems_version: 3.3.3
|
175
|
+
signing_key:
|
162
176
|
specification_version: 4
|
163
177
|
summary: Trello CLI app
|
164
178
|
test_files: []
|