stephencelis-ghi 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +12 -0
- data/README.rdoc +9 -3
- data/lib/ghi.rb +1 -1
- data/lib/ghi/api.rb +4 -0
- data/lib/ghi/cli.rb +47 -22
- metadata +1 -1
data/History.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 0.0.7 / 2009-04-25
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* Labels! Label and un-label at your whim.
|
6
|
+
|
7
|
+
|
8
|
+
* 1 minor enhancement
|
9
|
+
|
10
|
+
* Tail arguments are sometimes parsed. E.g., ghi -om "Issue message parsed".
|
11
|
+
|
12
|
+
|
1
13
|
=== 0.0.6 / 2009-04-25
|
2
14
|
|
3
15
|
* 2 minor enhancements
|
data/README.rdoc
CHANGED
@@ -15,21 +15,25 @@ Get:
|
|
15
15
|
|
16
16
|
Go:
|
17
17
|
|
18
|
-
% ghi
|
19
18
|
Usage: ghi [options]
|
20
19
|
-l, --list [state|term|number]
|
21
20
|
--search, --show
|
22
|
-
-o, --open
|
21
|
+
-o, --open [title|number]
|
22
|
+
--reopen
|
23
23
|
-c, --closed, --close [number]
|
24
24
|
-e, --edit [number]
|
25
25
|
-r, --repo, --repository [name]
|
26
26
|
-m, --comment [number|comment]
|
27
|
+
-t, --label [number] [label]
|
27
28
|
--claim [number]
|
29
|
+
-d, --unlabel [number] [label]
|
30
|
+
-V, --version
|
31
|
+
-h, --help
|
28
32
|
|
29
33
|
|
30
34
|
== EXAMPLE?
|
31
35
|
|
32
|
-
ghi works simply from within
|
36
|
+
ghi works simply from within a repository. Some short examples:
|
33
37
|
|
34
38
|
ghi -l # Lists all open issues
|
35
39
|
ghi -lc # Lists all closed issues
|
@@ -45,6 +49,8 @@ ghi works simply from within the directory. Some short examples:
|
|
45
49
|
ghi -c1 -m "Comment" # Closes issue with specified comment
|
46
50
|
ghi -o1 # Reopens 1 (accepts comments, too)
|
47
51
|
ghi -m1 # Comments on issue 1 (in your $EDITOR)
|
52
|
+
ghi -t1 "tag" # Labels issue 1 with "tag"
|
53
|
+
ghi -d1 "tag" # Removes the label, "tag"
|
48
54
|
ghi --claim 1 # Tags issue 1 with your GitHub username
|
49
55
|
|
50
56
|
|
data/lib/ghi.rb
CHANGED
data/lib/ghi/api.rb
CHANGED
@@ -67,6 +67,8 @@ class GHI::API
|
|
67
67
|
res = YAML.load Net::HTTP.get(URI.parse(url(*args) + auth(true)))
|
68
68
|
raise ResponseError, errors(res) if res["error"]
|
69
69
|
res
|
70
|
+
rescue ArgumentError, URI::InvalidURIError
|
71
|
+
raise ResponseError, "GitHub hiccuped on your request"
|
70
72
|
end
|
71
73
|
|
72
74
|
def post(*args)
|
@@ -75,6 +77,8 @@ class GHI::API
|
|
75
77
|
res = YAML.load Net::HTTP.post_form(URI.parse(url(*args)), params).body
|
76
78
|
raise ResponseError, errors(res) if res["error"]
|
77
79
|
res
|
80
|
+
rescue ArgumentError, URI::InvalidURIError
|
81
|
+
raise ResponseError, "GitHub hiccuped on your request"
|
78
82
|
end
|
79
83
|
|
80
84
|
def errors(response)
|
data/lib/ghi/cli.rb
CHANGED
@@ -136,10 +136,15 @@ module GHI::CLI #:nodoc:
|
|
136
136
|
include FileHelper, FormattingHelper
|
137
137
|
|
138
138
|
attr_reader :message, :user, :repo, :api, :action, :state, :search_term,
|
139
|
-
:number, :title, :body, :label
|
139
|
+
:number, :title, :body, :label, :args
|
140
140
|
|
141
141
|
def initialize
|
142
|
-
option_parser.parse!(ARGV)
|
142
|
+
@args = option_parser.parse!(ARGV)
|
143
|
+
|
144
|
+
if action.nil?
|
145
|
+
puts option_parser
|
146
|
+
exit
|
147
|
+
end
|
143
148
|
|
144
149
|
`git config --get remote.origin.url`.match %r{([^:/]+)/([^/]+).git$}
|
145
150
|
@user ||= $1
|
@@ -147,17 +152,16 @@ module GHI::CLI #:nodoc:
|
|
147
152
|
@api = GHI::API.new user, repo
|
148
153
|
|
149
154
|
case action
|
150
|
-
when :search
|
151
|
-
when :list
|
152
|
-
when :show
|
153
|
-
when :open
|
154
|
-
when :edit
|
155
|
-
when :close
|
156
|
-
when :reopen
|
157
|
-
when :comment
|
158
|
-
|
159
|
-
when :
|
160
|
-
else puts option_parser
|
155
|
+
when :search then search
|
156
|
+
when :list then list
|
157
|
+
when :show then show
|
158
|
+
when :open then open
|
159
|
+
when :edit then edit
|
160
|
+
when :close then close
|
161
|
+
when :reopen then reopen
|
162
|
+
when :comment then comment
|
163
|
+
when :label, :claim then add_label
|
164
|
+
when :unlabel then remove_label
|
161
165
|
end
|
162
166
|
rescue GHI::API::InvalidConnection
|
163
167
|
warn "#{File.basename $0}: not a GitHub repo"
|
@@ -208,7 +212,7 @@ module GHI::CLI #:nodoc:
|
|
208
212
|
@action = :list
|
209
213
|
@state = :open
|
210
214
|
when /^m$/
|
211
|
-
|
215
|
+
@title = ARGV * " "
|
212
216
|
else
|
213
217
|
@title = v
|
214
218
|
end
|
@@ -222,6 +226,8 @@ module GHI::CLI #:nodoc:
|
|
222
226
|
when /^l/, nil
|
223
227
|
@action = :list
|
224
228
|
@state = :closed
|
229
|
+
when nil
|
230
|
+
raise OptionParser::MissingArgument
|
225
231
|
else
|
226
232
|
raise OptionParser::InvalidOption
|
227
233
|
end
|
@@ -233,10 +239,10 @@ module GHI::CLI #:nodoc:
|
|
233
239
|
@action = :edit
|
234
240
|
@state = :closed
|
235
241
|
@number = v.to_i
|
236
|
-
when
|
237
|
-
raise OptionParser::AmbiguousOption # TODO: Parse args for message.
|
238
|
-
else
|
242
|
+
when nil
|
239
243
|
raise OptionParser::MissingArgument
|
244
|
+
else
|
245
|
+
raise OptionParser::InvalidOption
|
240
246
|
end
|
241
247
|
end
|
242
248
|
|
@@ -257,12 +263,29 @@ module GHI::CLI #:nodoc:
|
|
257
263
|
end
|
258
264
|
end
|
259
265
|
|
266
|
+
opts.on("-t", "--label [number] [label]") do |v|
|
267
|
+
raise OptionParser::MissingArgument if v.nil?
|
268
|
+
@action ||= :label
|
269
|
+
@number = v.to_i
|
270
|
+
end
|
271
|
+
|
260
272
|
opts.on("--claim [number]") do |v|
|
273
|
+
raise OptionParser::MissingArgument if v.nil?
|
261
274
|
@action = :claim
|
262
275
|
@number = v.to_i
|
263
276
|
@label = GHI.login
|
264
277
|
end
|
265
278
|
|
279
|
+
opts.on("-d", "--unlabel [number] [label]") do |v|
|
280
|
+
@action = :unlabel
|
281
|
+
case v
|
282
|
+
when /^\d+$/
|
283
|
+
@number = v.to_i
|
284
|
+
when /^\w+$/
|
285
|
+
@label = v
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
266
289
|
opts.on_tail("-V", "--version") do
|
267
290
|
puts "#{File.basename($0)}: v#{GHI::VERSION}"
|
268
291
|
exit
|
@@ -334,16 +357,18 @@ module GHI::CLI #:nodoc:
|
|
334
357
|
puts "(comment #{comment["status"]})" if comment
|
335
358
|
end
|
336
359
|
|
337
|
-
def
|
338
|
-
|
360
|
+
def add_label
|
361
|
+
new_label = label || body || @args * " "
|
362
|
+
labels = api.add_label new_label, number
|
339
363
|
puts action_format
|
340
364
|
puts indent(labels.join(", "))
|
341
365
|
end
|
342
366
|
|
343
|
-
def
|
344
|
-
|
367
|
+
def remove_label
|
368
|
+
new_label = label || body || @args * " "
|
369
|
+
labels = api.remove_label new_label, number
|
345
370
|
puts action_format
|
346
|
-
puts indent(labels.join(", "))
|
371
|
+
puts indent(labels.empty? ? "no labels" : labels.join(", "))
|
347
372
|
end
|
348
373
|
|
349
374
|
def comment
|