ubalo 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ubalo +16 -7
- data/lib/ubalo.rb +12 -4
- metadata +7 -7
data/bin/ubalo
CHANGED
@@ -195,21 +195,27 @@ end
|
|
195
195
|
desc 'Run a pod'
|
196
196
|
arg_name '<pod name>'
|
197
197
|
command :run do |c|
|
198
|
+
c.desc 'Use JSON for input and output'
|
199
|
+
c.switch :json
|
200
|
+
|
198
201
|
c.action do |global_options,options,args|
|
199
202
|
pod_name = args.shift
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
+
if options.json
|
204
|
+
args = receive_json_from_stdin
|
205
|
+
response = ubalo.submit_task_json(args)
|
206
|
+
else
|
207
|
+
$stderr.print "Running #{pod_name}..."
|
208
|
+
response = ubalo.submit_task(pod_name, args.join(" "))
|
209
|
+
end
|
203
210
|
task_label = response.fetch('label')
|
204
|
-
|
205
|
-
result
|
206
|
-
ubalo.show_result(result)
|
211
|
+
result = ubalo.wait_task(task_label, options.json)
|
212
|
+
ubalo.show_result(result, options.json)
|
207
213
|
end
|
208
214
|
end
|
209
215
|
|
210
216
|
def receive_json_from_stdin
|
211
217
|
if $stdin.tty?
|
212
|
-
raise "please pipe to stdin when using --json"
|
218
|
+
raise UbaloMessage, "please pipe to stdin when using --json"
|
213
219
|
else
|
214
220
|
JSON.parse($stdin.read)
|
215
221
|
end
|
@@ -484,6 +490,9 @@ on_error do |exception|
|
|
484
490
|
when UbaloExit
|
485
491
|
# Normal exit, preserving the correct exit code.
|
486
492
|
exit exception.message
|
493
|
+
when UbaloMessage
|
494
|
+
$stderr.puts "Error: #{exception.message}"
|
495
|
+
exit 1
|
487
496
|
else
|
488
497
|
$stderr.puts "Error! Unfortunately something went wrong. Please contact us: errors@ubalo.com."
|
489
498
|
raise # and go on to raise
|
data/lib/ubalo.rb
CHANGED
@@ -45,6 +45,10 @@ class UbaloExit < StandardError
|
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
+
class UbaloMessage < StandardError
|
49
|
+
|
50
|
+
end
|
51
|
+
|
48
52
|
class Ubalo
|
49
53
|
class << self
|
50
54
|
def format_task task
|
@@ -113,15 +117,19 @@ class Ubalo
|
|
113
117
|
post(:submit_task, hash)
|
114
118
|
end
|
115
119
|
|
116
|
-
def wait_task(label)
|
120
|
+
def wait_task(label, silent=false)
|
117
121
|
60.times do
|
118
122
|
h = check_task(label)
|
119
123
|
if %w{complete failed}.include?(h['state'])
|
120
|
-
|
124
|
+
unless silent
|
125
|
+
$stderr.puts " done."
|
126
|
+
end
|
121
127
|
return h
|
122
128
|
end
|
123
|
-
|
124
|
-
|
129
|
+
unless silent
|
130
|
+
$stderr.print '.'
|
131
|
+
$stderr.flush
|
132
|
+
end
|
125
133
|
sleep 0.5
|
126
134
|
end
|
127
135
|
$stderr.puts
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubalo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-07 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156840200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156840200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156839340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156839340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rest-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156838200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.6.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156838200
|
47
47
|
description: CLI and API client for Ubalo
|
48
48
|
email: dev@ubalo.com
|
49
49
|
executables:
|