wip-cli 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +2 -2
- data/README.md +12 -3
- data/bin/console +0 -1
- data/lib/wip.rb +3 -0
- data/lib/wip/auth.rb +5 -5
- data/lib/wip/cli.rb +22 -1
- data/lib/wip/client.rb +1 -1
- data/lib/wip/helpers/graphql_helper.rb +11 -0
- data/lib/wip/todo.rb +60 -7
- data/lib/wip/user.rb +79 -0
- data/lib/wip/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9c05cd1f964991c2b44e8d235846ebaf3da18dd2ab0c47d8731801a75c4232
|
4
|
+
data.tar.gz: 6d439e90a3ad971779e7cabbde4f4790f4a3884286c9ec70d97954f8e13ec81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059174a36ae832449877c49cf88695c9530006c04737702dc60e593e092194ebb5aa8af38c0e648eda813cbd01f829a6aa135bb81d7b5c7e316c0ae041f53f97'
|
7
|
+
data.tar.gz: f2a19480b29b25bb41dc0ad35336e127b737bbfa0ecf671fff8ea2dd8e596fbb08a09aa2a178274901743d74f29175e3107bc0958373a8bb607b763458675ec4
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,20 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.2.0] - 2020-11-12
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Added options to uncomplete a todo: `wip complete -u 123 `
|
10
|
+
- Added command to delete a todo: `wip delete 123`
|
11
|
+
- Added command to get any users todos: `wip todos -u sowenjub`
|
12
|
+
- Added command to get viewer todos: `wip todos`
|
13
|
+
- Added method to get viewer: `Wip::User.viewer`
|
14
|
+
|
5
15
|
## [1.1.0] - 2020-11-11
|
6
16
|
|
17
|
+
### Changed
|
18
|
+
|
7
19
|
- Renamed command from wipco to wip
|
8
20
|
- Renamed gem from wipco to wip-cli
|
9
21
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,11 +22,20 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Define an ENV var named `WIP_API_KEY` with your [api key](https://wip.co/api).
|
24
24
|
|
25
|
-
|
25
|
+
### Adding a todo & completing it
|
26
26
|
|
27
|
-
`wip
|
27
|
+
* `wip todo "Grab a cup of ☕️"`
|
28
|
+
* `wip complete 123`
|
29
|
+
* `wip complete -u 123` to uncomplete a todo
|
30
|
+
* `wip delete 123`
|
28
31
|
|
29
|
-
|
32
|
+
And to log a completed todo:
|
33
|
+
* `wip done "Installed wip-cli gem"`
|
34
|
+
|
35
|
+
### Managing todos
|
36
|
+
|
37
|
+
You can list your todos (see `wip help todos` for all the options):
|
38
|
+
`wip todos -u sowenjub -f "#nomeattoday" -l 10`
|
30
39
|
|
31
40
|
## Development
|
32
41
|
|
data/bin/console
CHANGED
data/lib/wip.rb
CHANGED
data/lib/wip/auth.rb
CHANGED
data/lib/wip/cli.rb
CHANGED
@@ -7,8 +7,9 @@ class Wip::CLI < Thor
|
|
7
7
|
class_option :verbose, :type => :boolean, :aliases => "-v"
|
8
8
|
|
9
9
|
desc "complete [ID]", "Mark a todo as completed"
|
10
|
+
method_option :undo, type: :boolean, aliases: '-u'
|
10
11
|
def complete(todo_id)
|
11
|
-
todo = Wip::Todo.complete(todo_id)
|
12
|
+
todo = options.undo ? Wip::Todo.uncomplete(todo_id) : Wip::Todo.complete(todo_id)
|
12
13
|
puts todo.description
|
13
14
|
end
|
14
15
|
|
@@ -18,9 +19,29 @@ class Wip::CLI < Thor
|
|
18
19
|
puts todo.description
|
19
20
|
end
|
20
21
|
|
22
|
+
desc "delete [ID]", "Delete a todo"
|
23
|
+
def delete(todo_id)
|
24
|
+
todo = Wip::Todo.delete(todo_id)
|
25
|
+
puts todo.description
|
26
|
+
end
|
27
|
+
|
21
28
|
desc "todo [BODY]", "Create a new todo"
|
22
29
|
def todo(body)
|
23
30
|
todo = Wip::Todo.create(body: body)
|
24
31
|
puts todo.description
|
25
32
|
end
|
33
|
+
|
34
|
+
desc "todos", "List viewer todos"
|
35
|
+
method_option :completed, type: :boolean, aliases: '-c'
|
36
|
+
method_option :filter, type: :string, aliases: '-f'
|
37
|
+
method_option :limit, type: :numeric, aliases: '-l', default: 5
|
38
|
+
method_option :order, type: :string, aliases: '-o', default: "completed_at:desc"
|
39
|
+
method_option :username, type: :string, aliases: '-u'
|
40
|
+
def todos
|
41
|
+
todos_options = options.slice("completed", "filter", "limit", "order")
|
42
|
+
user = options.username.nil? ? Wip::User.viewer(todos: todos_options) : Wip::User.find(username: options.username, todos: todos_options)
|
43
|
+
user.todos.each do |todo|
|
44
|
+
puts todo.description
|
45
|
+
end
|
46
|
+
end
|
26
47
|
end
|
data/lib/wip/client.rb
CHANGED
data/lib/wip/todo.rb
CHANGED
@@ -3,18 +3,27 @@ require "wip"
|
|
3
3
|
require "wip/client"
|
4
4
|
|
5
5
|
class Wip::Todo
|
6
|
-
|
6
|
+
|
7
|
+
ATTRIBUTES = %i(id body completed_at)
|
8
|
+
|
9
|
+
attr_accessor *ATTRIBUTES
|
10
|
+
attr_accessor :deleted
|
7
11
|
attr_reader :client
|
8
12
|
|
13
|
+
def self.collection_query(**args)
|
14
|
+
conditions = Wip::GraphqlHelper.query_conditions(**args)
|
15
|
+
%{ todos#{conditions} { #{default_selection} } }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.default_selection
|
19
|
+
ATTRIBUTES.join("\n ")
|
20
|
+
end
|
21
|
+
|
9
22
|
def self.find(id)
|
10
23
|
client = Wip::Client.new
|
11
24
|
find_query = %{
|
12
25
|
{
|
13
|
-
todo(id: \"#{id}\") {
|
14
|
-
id
|
15
|
-
body
|
16
|
-
completed_at
|
17
|
-
}
|
26
|
+
todo(id: \"#{id}\") {#{default_selection}}
|
18
27
|
}
|
19
28
|
}
|
20
29
|
client.request find_query
|
@@ -37,6 +46,18 @@ class Wip::Todo
|
|
37
46
|
todo
|
38
47
|
end
|
39
48
|
|
49
|
+
def self.uncomplete(id)
|
50
|
+
todo = find id
|
51
|
+
todo.uncomplete
|
52
|
+
todo
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.delete(id)
|
56
|
+
todo = find id
|
57
|
+
todo.delete
|
58
|
+
todo
|
59
|
+
end
|
60
|
+
|
40
61
|
|
41
62
|
def initialize(id: nil, body: nil, completed_at: nil)
|
42
63
|
@id = id
|
@@ -58,7 +79,7 @@ class Wip::Todo
|
|
58
79
|
end
|
59
80
|
|
60
81
|
def icon
|
61
|
-
done? ? "✅" : "🚧"
|
82
|
+
deleted ? "🗑" : (done? ? "✅" : "🚧")
|
62
83
|
end
|
63
84
|
|
64
85
|
def complete
|
@@ -68,6 +89,13 @@ class Wip::Todo
|
|
68
89
|
end
|
69
90
|
end
|
70
91
|
|
92
|
+
def uncomplete
|
93
|
+
client.request uncomplete_query
|
94
|
+
client.data("uncompleteTodo").tap do |params|
|
95
|
+
@completed_at = nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
71
99
|
def save
|
72
100
|
client.request create_query
|
73
101
|
client.data("createTodo").tap do |params|
|
@@ -75,6 +103,11 @@ class Wip::Todo
|
|
75
103
|
end
|
76
104
|
end
|
77
105
|
|
106
|
+
def delete
|
107
|
+
client.request delete_query
|
108
|
+
@deleted = !client.data("deleteTodo").nil?
|
109
|
+
end
|
110
|
+
|
78
111
|
private
|
79
112
|
def create_query
|
80
113
|
%{
|
@@ -88,6 +121,14 @@ class Wip::Todo
|
|
88
121
|
}
|
89
122
|
end
|
90
123
|
|
124
|
+
def delete_query
|
125
|
+
%{
|
126
|
+
mutation deleteTodo {
|
127
|
+
deleteTodo(id: #{id})
|
128
|
+
}
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
91
132
|
def complete_query
|
92
133
|
%{
|
93
134
|
mutation completeTodo {
|
@@ -100,6 +141,18 @@ class Wip::Todo
|
|
100
141
|
}
|
101
142
|
end
|
102
143
|
|
144
|
+
def uncomplete_query
|
145
|
+
%{
|
146
|
+
mutation uncompleteTodo {
|
147
|
+
uncompleteTodo(id: #{id}) {
|
148
|
+
id
|
149
|
+
body
|
150
|
+
completed_at
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
end
|
155
|
+
|
103
156
|
def to_params
|
104
157
|
[:body, :completed_at].collect do |key|
|
105
158
|
value = send(key).nil? ? "null" : "\"#{send(key)}\""
|
data/lib/wip/user.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "date"
|
2
|
+
require "wip"
|
3
|
+
require "wip/client"
|
4
|
+
|
5
|
+
class Wip::User
|
6
|
+
attr_accessor :avatar_url, :best_streak, :completed_todos_count, :first_name, :id, :last_name, :streak, :streaking, :time_zone, :url, :username, :todos
|
7
|
+
|
8
|
+
def self.default_selection(todos: {})
|
9
|
+
todos_selection = Wip::Todo.collection_query(**todos)
|
10
|
+
%{
|
11
|
+
avatar_url
|
12
|
+
best_streak
|
13
|
+
completed_todos_count
|
14
|
+
first_name
|
15
|
+
id
|
16
|
+
last_name
|
17
|
+
streak
|
18
|
+
streaking
|
19
|
+
time_zone
|
20
|
+
#{todos_selection}
|
21
|
+
url
|
22
|
+
username
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.viewer(todos: {})
|
27
|
+
client = Wip::Client.new
|
28
|
+
find_query = %{
|
29
|
+
{
|
30
|
+
viewer {#{default_selection(todos: todos)}}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
client.request find_query
|
34
|
+
parse client.data("viewer")
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.find(id = nil, username: nil, todos: {})
|
38
|
+
client = Wip::Client.new
|
39
|
+
find_by = id.nil? ? "username: \"#{username}\"" : "id: #{id}"
|
40
|
+
find_query = %{
|
41
|
+
{
|
42
|
+
user(#{find_by}) {#{default_selection(todos: todos)}}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
client.request find_query
|
46
|
+
parse client.data("user")
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(avatar_url: nil, best_streak: nil, completed_todos_count: nil, first_name: nil, id: nil, last_name: nil, streak: nil, streaking: nil, time_zone: nil, url: nil, username: nil, todos: [])
|
50
|
+
@avatar_url = avatar_url
|
51
|
+
@best_streak = best_streak
|
52
|
+
@completed_todos_count = completed_todos_count
|
53
|
+
@first_name = first_name
|
54
|
+
@id = id
|
55
|
+
@last_name = last_name
|
56
|
+
@streak = streak
|
57
|
+
@streaking = streaking
|
58
|
+
@time_zone = time_zone
|
59
|
+
@url = url
|
60
|
+
@username = username
|
61
|
+
@todos = todos
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.parse(data)
|
65
|
+
new.tap do |user|
|
66
|
+
data.each do |key, raw_value|
|
67
|
+
value = case key
|
68
|
+
when "id"
|
69
|
+
raw_value.to_i
|
70
|
+
when "todos"
|
71
|
+
raw_value.collect { |v| Wip::Todo.parse v }
|
72
|
+
else
|
73
|
+
raw_value
|
74
|
+
end
|
75
|
+
user.send("#{key}=", value)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/wip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wip-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Joubay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -89,7 +89,9 @@ files:
|
|
89
89
|
- lib/wip/auth.rb
|
90
90
|
- lib/wip/cli.rb
|
91
91
|
- lib/wip/client.rb
|
92
|
+
- lib/wip/helpers/graphql_helper.rb
|
92
93
|
- lib/wip/todo.rb
|
94
|
+
- lib/wip/user.rb
|
93
95
|
- lib/wip/version.rb
|
94
96
|
- wip-cli.gemspec
|
95
97
|
homepage: https://github.com/sowenjub/wip-cli
|