pi 0.1.33 → 0.1.34
Sign up to get free protection for your applications and to get access to all the features.
- data/README +10 -13
- data/lib/cli.rb +1 -1
- data/lib/cli/choose_helper.rb +50 -54
- data/lib/cli/commands/apps.rb +139 -139
- data/lib/cli/commands/dns.rb +50 -50
- data/lib/cli/commands/misc.rb +12 -11
- data/lib/cli/commands/projects.rb +67 -67
- data/lib/cli/commands/services.rb +56 -56
- data/lib/cli/commands/user.rb +29 -33
- data/lib/cli/interact_helper.rb +9 -9
- data/lib/cli/runner.rb +129 -129
- data/lib/cli/usage.rb +11 -11
- data/lib/cli/version.rb +1 -1
- data/lib/pi/client.rb +80 -89
- data/lib/pi/const.rb +1 -1
- metadata +147 -130
data/lib/cli/commands/dns.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module PI::Cli::Command
|
2
2
|
class Dns < Base
|
3
|
-
include PI::Cli::ChooseHelper
|
3
|
+
include PI::Cli::ChooseHelper
|
4
4
|
include PI::Cli::InteractHelper
|
5
|
-
|
5
|
+
|
6
6
|
def app_dns(appid_or_appname=nil)
|
7
7
|
all_opts = total_opts
|
8
8
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(target)/i}
|
@@ -20,8 +20,8 @@ module PI::Cli::Command
|
|
20
20
|
dns.each do |s|
|
21
21
|
display "#{s}"
|
22
22
|
end
|
23
|
-
end
|
24
|
-
|
23
|
+
end
|
24
|
+
|
25
25
|
def map_dns(appid_or_appname=nil)
|
26
26
|
all_opts = total_opts
|
27
27
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(target|dns)/i}
|
@@ -39,9 +39,9 @@ module PI::Cli::Command
|
|
39
39
|
appid = (appid == nil ? app[:id] : appid)
|
40
40
|
dns = client.usable_dns(appid)
|
41
41
|
err "No usable dns!" if dns.nil? || dns.empty?
|
42
|
-
if dnsname
|
42
|
+
if dnsname
|
43
43
|
usable_dnsnames = dns.collect { |d| d[:name] }
|
44
|
-
err "Invalid dns name" unless usable_dnsnames.include?(dnsname)
|
44
|
+
err "Invalid dns name" unless usable_dnsnames.include?(dnsname)
|
45
45
|
tmp = dnsname.split(",")
|
46
46
|
manifest = Array.new
|
47
47
|
tmp.each do |t|
|
@@ -49,22 +49,22 @@ module PI::Cli::Command
|
|
49
49
|
end
|
50
50
|
else
|
51
51
|
manifest = asks "Select dns, indexed list?", :choices => dns.collect { |d| d[:name] }, :indexed => true
|
52
|
-
end
|
52
|
+
end
|
53
53
|
display "Mapping dns: ",false
|
54
|
-
|
55
|
-
t = Thread.new do
|
54
|
+
|
55
|
+
t = Thread.new do
|
56
56
|
loop do
|
57
|
-
display '.', false
|
57
|
+
display '.', false
|
58
58
|
sleep (1)
|
59
59
|
break unless t.alive?
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
client.map_dns(appid,manifest)
|
64
64
|
Thread.kill(t)
|
65
|
-
display "OK".green
|
66
|
-
end
|
67
|
-
|
65
|
+
display "OK".green
|
66
|
+
end
|
67
|
+
|
68
68
|
def unmap_dns(appid_or_appname=nil)
|
69
69
|
all_opts = total_opts
|
70
70
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(target|dns)/i}
|
@@ -76,18 +76,18 @@ module PI::Cli::Command
|
|
76
76
|
app, appid = choose_app_help_target_not_all(appid_or_appname)
|
77
77
|
appid = (appid == nil ? app[:id] : appid)
|
78
78
|
dns = client.app_dns(appid)
|
79
|
-
err "No mapped dns!" if dns.nil? || dns.empty?
|
80
|
-
if dnsname
|
79
|
+
err "No mapped dns!" if dns.nil? || dns.empty?
|
80
|
+
if dnsname
|
81
81
|
urls = dnsname.split(",")
|
82
82
|
else
|
83
83
|
urls = asks "Select DNS", :choices => dns, :indexed => true
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
urls.each do |url|
|
87
87
|
do_unmap_dns(appid, url)
|
88
|
-
end
|
88
|
+
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def dns
|
92
92
|
all_opts = total_opts
|
93
93
|
all_opts.each_value do |value|
|
@@ -95,7 +95,7 @@ module PI::Cli::Command
|
|
95
95
|
end
|
96
96
|
client.check_login_status
|
97
97
|
dns = client.dns
|
98
|
-
return display "No Services" if dns.nil? || dns.empty?
|
98
|
+
return display "No Services" if dns.nil? || dns.empty?
|
99
99
|
return display JSON.pretty_generate(dns) if @options[:json]
|
100
100
|
dns.sort! {|a, b| a[:name] <=> b[:name] }
|
101
101
|
dns_table = table do |t|
|
@@ -106,7 +106,7 @@ module PI::Cli::Command
|
|
106
106
|
end
|
107
107
|
display dns_table
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def zones
|
111
111
|
all_opts = total_opts
|
112
112
|
all_opts.each_value do |value|
|
@@ -124,7 +124,7 @@ module PI::Cli::Command
|
|
124
124
|
end
|
125
125
|
display zones_table
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
def create_dns(dnsname=nil)
|
129
129
|
all_opts = total_opts
|
130
130
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(projectid|desc|zoneid)/i}
|
@@ -135,9 +135,9 @@ module PI::Cli::Command
|
|
135
135
|
projectid = @options[:projectid]
|
136
136
|
description = @options[:desc]
|
137
137
|
zoneid = @options[:zoneid]
|
138
|
-
if dnsname
|
138
|
+
if dnsname
|
139
139
|
if not check_name_valid?(dnsname)
|
140
|
-
err "Invalid dns name '#{dnsname}'."
|
140
|
+
err "Invalid dns name '#{dnsname}'."
|
141
141
|
end
|
142
142
|
end
|
143
143
|
dns_zone = client.dns_zone_list
|
@@ -149,8 +149,8 @@ module PI::Cli::Command
|
|
149
149
|
end
|
150
150
|
err"The dns zone id is not exist!" if zoneid_flag != true
|
151
151
|
end
|
152
|
-
|
153
|
-
projects = client.projects
|
152
|
+
|
153
|
+
projects = client.projects
|
154
154
|
if projectid
|
155
155
|
projectid_flag = false
|
156
156
|
projects.each do |p|
|
@@ -158,12 +158,12 @@ module PI::Cli::Command
|
|
158
158
|
end
|
159
159
|
err"Invalid project id: #{projectid}" if projectid_flag != true
|
160
160
|
else
|
161
|
-
projectname = ask"Project name", :choices => projects.collect { |p| p[:name] }, :indexed => true
|
161
|
+
projectname = ask"Project name", :choices => projects.collect { |p| p[:name] }, :indexed => true
|
162
162
|
projects.each do |p|
|
163
163
|
projectid = p[:id] if p[:name] == projectname
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
167
|
unless zoneid
|
168
168
|
zonename = ask"Select dns zone", :choices => dns_zone.collect { |d| d[:name] }, :indexed => true
|
169
169
|
dns_zone.each do |d|
|
@@ -171,24 +171,24 @@ module PI::Cli::Command
|
|
171
171
|
end
|
172
172
|
err"Invalid zone" if zoneid.nil?
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
loop{
|
176
176
|
dnsname = ask"DNS name" unless dnsname
|
177
177
|
tmp = client.verify_dns(dnsname, zoneid)
|
178
178
|
if not check_name_valid?(dnsname)
|
179
|
-
display "Invalid dns name '#{dnsname}'."
|
179
|
+
display "Invalid dns name '#{dnsname}'."
|
180
180
|
dnsname =nil
|
181
181
|
next
|
182
182
|
else if tmp[1] == "false"
|
183
|
-
display "DNS '#{dnsname}' already exists."
|
183
|
+
display "DNS '#{dnsname}' already exists."
|
184
184
|
dnsname =nil
|
185
185
|
next
|
186
186
|
else
|
187
187
|
break
|
188
188
|
end
|
189
189
|
end
|
190
|
-
}
|
191
|
-
# dnsname = dnsname.concat(".#{zone}")
|
190
|
+
}
|
191
|
+
# dnsname = dnsname.concat(".#{zone}")
|
192
192
|
description = ask"Description", :default => nil unless description
|
193
193
|
manifest = {
|
194
194
|
:name => dnsname,
|
@@ -197,9 +197,9 @@ module PI::Cli::Command
|
|
197
197
|
:bak => description
|
198
198
|
}
|
199
199
|
client.create_dns(manifest)
|
200
|
-
display"OK".green
|
200
|
+
display"OK".green
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
def delete_dns(dnsid=nil)
|
204
204
|
all_opts = total_opts
|
205
205
|
all_opts.each_value do |value|
|
@@ -212,7 +212,7 @@ module PI::Cli::Command
|
|
212
212
|
client.delete_dns(dnsid)
|
213
213
|
display"OK".green
|
214
214
|
end
|
215
|
-
|
215
|
+
|
216
216
|
def register_dns(dnsid=nil)
|
217
217
|
all_opts = total_opts
|
218
218
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(target|continent|country)/i}
|
@@ -247,7 +247,7 @@ module PI::Cli::Command
|
|
247
247
|
display "Select continent: #{continent}"
|
248
248
|
continent = continents.invert["#{continent}"]
|
249
249
|
end
|
250
|
-
if continent.to_s == "DEFAULT"
|
250
|
+
if continent.to_s == "DEFAULT"
|
251
251
|
manifest = {
|
252
252
|
:continentCode => continent,
|
253
253
|
:countryCode => "DEFAULT"
|
@@ -266,11 +266,11 @@ module PI::Cli::Command
|
|
266
266
|
:continentCode => continent,
|
267
267
|
:countryCode => country
|
268
268
|
}
|
269
|
-
end
|
269
|
+
end
|
270
270
|
client.register_dns(dnsid, target, manifest)
|
271
271
|
display "OK".green
|
272
272
|
end
|
273
|
-
|
273
|
+
|
274
274
|
def deregister_dns(dnsid=nil)
|
275
275
|
all_opts = total_opts
|
276
276
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(recordid)/i}
|
@@ -299,7 +299,7 @@ module PI::Cli::Command
|
|
299
299
|
client.deregister_dns(recordid)
|
300
300
|
display "OK".green
|
301
301
|
end
|
302
|
-
|
302
|
+
|
303
303
|
def dns_records(dnsid=nil)
|
304
304
|
all_opts = total_opts
|
305
305
|
all_opts.each_value do |value|
|
@@ -326,24 +326,24 @@ module PI::Cli::Command
|
|
326
326
|
end
|
327
327
|
end
|
328
328
|
display record_info_table
|
329
|
-
end
|
329
|
+
end
|
330
330
|
end
|
331
|
-
|
331
|
+
|
332
332
|
private
|
333
|
-
|
333
|
+
|
334
334
|
def do_unmap_dns(appid, url)
|
335
|
-
display "Unmapping dns '#{url}': ",false
|
336
|
-
t = Thread.new do
|
335
|
+
display "Unmapping dns '#{url}': ",false
|
336
|
+
t = Thread.new do
|
337
337
|
loop do
|
338
|
-
display '.', false
|
338
|
+
display '.', false
|
339
339
|
sleep (1)
|
340
340
|
break unless t.alive?
|
341
341
|
end
|
342
|
-
end
|
342
|
+
end
|
343
343
|
client.unmap_dns(appid, url)
|
344
344
|
Thread.kill(t)
|
345
345
|
display "OK".green
|
346
346
|
end
|
347
|
-
|
347
|
+
|
348
348
|
end
|
349
349
|
end
|
data/lib/cli/commands/misc.rb
CHANGED
@@ -4,20 +4,21 @@ module PI::Cli::Command
|
|
4
4
|
def version
|
5
5
|
say "pi #{PI::Cli::VERSION}"
|
6
6
|
end
|
7
|
-
|
8
|
-
def set_target(target_url)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
target_url = "http://api
|
7
|
+
|
8
|
+
def set_target(target_url)
|
9
|
+
case target_url
|
10
|
+
when "www"
|
11
|
+
target_url = "http://api.samsungcloud.org"
|
12
|
+
when "staging"
|
13
|
+
target_url = "http://api.staging.samsungcloud.org"
|
14
|
+
when "qa"
|
15
|
+
target_url = "http://api.qa.samsungcloud.org"
|
16
16
|
else
|
17
|
-
|
17
|
+
|
18
18
|
end
|
19
|
-
target_url = target_url.gsub(/\/+$/, '')
|
19
|
+
#target_url = target_url.gsub(/\/+$/, '')
|
20
20
|
client = PI::Client.new(target_url)
|
21
|
+
PI::Cli::Config.store_target(target_url)
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
@@ -17,42 +17,42 @@ module PI::Cli::Command
|
|
17
17
|
client.check_login_status
|
18
18
|
user = client.user_info
|
19
19
|
proj_sum = client.project_sum
|
20
|
-
total_proj = Integer(proj_sum[1])
|
21
|
-
return display "No Projects" if total_proj == 0
|
20
|
+
total_proj = Integer(proj_sum[1])
|
21
|
+
return display "No Projects" if total_proj == 0
|
22
22
|
pageNum = -1
|
23
|
-
numPerPage = -1
|
23
|
+
numPerPage = -1
|
24
24
|
if total_proj >= 50
|
25
|
-
puts "Total projects: #{total_proj}."
|
26
|
-
numPerPage = nil
|
25
|
+
puts "Total projects: #{total_proj}."
|
26
|
+
numPerPage = nil
|
27
27
|
loop{
|
28
28
|
numPerPage = ask "Number per page"
|
29
29
|
if not numPerPage =~ /^[1-9]\d*$/
|
30
|
-
display "Invalid Number! Please input number from 1 to #{total_proj}"
|
30
|
+
display "Invalid Number! Please input number from 1 to #{total_proj}"
|
31
31
|
numPerPage =nil
|
32
32
|
next
|
33
33
|
else
|
34
34
|
break
|
35
35
|
end
|
36
|
-
}
|
36
|
+
}
|
37
37
|
numPerPage = numPerPage.to_i
|
38
38
|
maxpage = (total_proj.to_f/numPerPage).ceil
|
39
39
|
loop{
|
40
40
|
pageNum = ask "Page number"
|
41
41
|
if not pageNum =~ /^[1-9]\d*$/
|
42
|
-
display "Invalid Number! Please input number from 1 to #{maxpage}"
|
42
|
+
display "Invalid Number! Please input number from 1 to #{maxpage}"
|
43
43
|
pageNum =nil
|
44
44
|
next
|
45
45
|
else
|
46
46
|
break
|
47
47
|
end
|
48
|
-
}
|
49
|
-
pageNum = pageNum.to_i
|
50
|
-
end
|
48
|
+
}
|
49
|
+
pageNum = pageNum.to_i
|
50
|
+
end
|
51
51
|
projects = client.projects(pageNum, numPerPage)
|
52
52
|
return display "No Projects" if projects.nil? || projects.empty?
|
53
53
|
return display JSON.pretty_generate(projects) if @options[:json]
|
54
54
|
projects.sort! {|a, b| a[:name] <=> b[:name] }
|
55
|
-
display "\n"
|
55
|
+
display "\n"
|
56
56
|
projects_table = table do |t|
|
57
57
|
t.headings = 'ID', 'Name', 'Runtime', 'Framework', 'Git Type','GitUrl', 'Description'
|
58
58
|
projects.each do |project|
|
@@ -62,30 +62,30 @@ module PI::Cli::Command
|
|
62
62
|
display projects_table
|
63
63
|
end
|
64
64
|
|
65
|
-
def create_project(project=nil)
|
65
|
+
def create_project(project=nil)
|
66
66
|
all_opts = total_opts
|
67
67
|
all_opts.each_value do |value|
|
68
68
|
err "Invalid options" if value != nil
|
69
69
|
end
|
70
|
-
client.check_login_status
|
70
|
+
client.check_login_status
|
71
71
|
loop{
|
72
72
|
unless project
|
73
73
|
project = ask "Project Name"
|
74
74
|
err "Project Name required." if project.nil? || project.empty?
|
75
75
|
end
|
76
76
|
if not check_name_valid?(project)
|
77
|
-
display "Invalid project name '#{project}'."
|
77
|
+
display "Invalid project name '#{project}'."
|
78
78
|
project =nil
|
79
79
|
next
|
80
80
|
else if project_exists?(project)
|
81
|
-
display "Project '#{project}' already exists."
|
82
|
-
project =nil
|
81
|
+
display "Project '#{project}' already exists."
|
82
|
+
project =nil
|
83
83
|
next
|
84
|
-
else
|
84
|
+
else
|
85
85
|
break
|
86
86
|
end
|
87
87
|
end
|
88
|
-
}
|
88
|
+
}
|
89
89
|
|
90
90
|
runtimes = client.runtimes
|
91
91
|
err "No Runtimes" if runtimes.nil? || runtimes.empty?
|
@@ -98,19 +98,19 @@ module PI::Cli::Command
|
|
98
98
|
framework = ask "Select Framework", :choices => frameworks, :indexed => true
|
99
99
|
display "Selected Framework: ",false
|
100
100
|
display "#{framework}"
|
101
|
-
|
101
|
+
|
102
102
|
description = ask "Please enter in the description", :default => nil unless description
|
103
|
-
|
103
|
+
|
104
104
|
github_info = client.github_info
|
105
|
-
|
106
|
-
if github_info.nil?
|
105
|
+
|
106
|
+
if github_info.nil?
|
107
107
|
manifest = {
|
108
108
|
:name => "#{project}",
|
109
109
|
:runtime => "#{runtime}",
|
110
110
|
:framework => "#{framework}",
|
111
111
|
:description => "#{description}"
|
112
112
|
}
|
113
|
-
else
|
113
|
+
else
|
114
114
|
repositoryTypes =["cloudpi","github"]
|
115
115
|
repositoryType = ask "Select Repository Type", :choices => repositoryTypes, :indexed => true
|
116
116
|
display "Selected Repository Type: ",false
|
@@ -119,7 +119,7 @@ module PI::Cli::Command
|
|
119
119
|
if repositoryType == "github"
|
120
120
|
isNew = "yes"
|
121
121
|
publishTypes =["public","private"]
|
122
|
-
publishType = ask "Select Publish Type", :choices => publishTypes, :indexed => true
|
122
|
+
publishType = ask "Select Publish Type", :choices => publishTypes, :indexed => true
|
123
123
|
display "Selected publish Type: ",false
|
124
124
|
display "#{publishType}"
|
125
125
|
end
|
@@ -133,17 +133,17 @@ module PI::Cli::Command
|
|
133
133
|
:publishType => "#{publishType}"
|
134
134
|
}
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
display "Creating project \"#{project}\": ",false
|
138
|
-
|
139
|
-
t = Thread.new do
|
138
|
+
|
139
|
+
t = Thread.new do
|
140
140
|
loop do
|
141
|
-
display '.', false
|
141
|
+
display '.', false
|
142
142
|
sleep (1)
|
143
143
|
break unless t.alive?
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
client.create_project(project, manifest)
|
148
148
|
Thread.kill(t)
|
149
149
|
display "OK".green
|
@@ -160,29 +160,29 @@ module PI::Cli::Command
|
|
160
160
|
projectid = useproject[:id]
|
161
161
|
end
|
162
162
|
display "Deleting project: ",false
|
163
|
-
|
164
|
-
t = Thread.new do
|
163
|
+
|
164
|
+
t = Thread.new do
|
165
165
|
loop do
|
166
|
-
display '.', false
|
166
|
+
display '.', false
|
167
167
|
sleep (1)
|
168
168
|
break unless t.alive?
|
169
169
|
end
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
client.delete_project(projectid)
|
173
173
|
Thread.kill(t)
|
174
174
|
display 'OK'.green
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
def upload(projectid=nil)
|
178
178
|
all_opts = total_opts
|
179
179
|
all_opts_except_valid_opts = all_opts.delete_if{ |key,value| key.to_s =~ /(path|ver|desc)/i}
|
180
180
|
all_opts_except_valid_opts.each_value do |value|
|
181
181
|
err "Invalid options" if value != nil
|
182
182
|
end
|
183
|
-
client.check_login_status
|
183
|
+
client.check_login_status
|
184
184
|
path = @options[:path]
|
185
|
-
if path
|
185
|
+
if path
|
186
186
|
err "Not war file or path does not exist!" if not ((path =~ /\.(war)$/) && (File.exists? path))
|
187
187
|
end
|
188
188
|
version = @options[:ver]
|
@@ -193,37 +193,37 @@ module PI::Cli::Command
|
|
193
193
|
java_projects.sort! {|a, b| a[:name] <=> b[:name] }
|
194
194
|
if projectid
|
195
195
|
flag = nil
|
196
|
-
java_projects.each do |j|
|
196
|
+
java_projects.each do |j|
|
197
197
|
flag = true if projectid == j[:id].to_s
|
198
198
|
end
|
199
|
-
err "The project is not found or not a java project! " unless flag
|
200
|
-
else
|
199
|
+
err "The project is not found or not a java project! " unless flag
|
200
|
+
else
|
201
201
|
project = ask "Select Project", :choices => java_projects.collect { |j| j[:name] }, :indexed => true
|
202
202
|
display "Selected Project: ",false
|
203
203
|
display "#{project}"
|
204
204
|
project = client.project_search(project)
|
205
205
|
projectid = project[:id]
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
if version
|
209
209
|
err "Invalid version name length. The max length of name is 30" unless check_version_name_valid?(version)
|
210
|
-
tmp = client.project_binary_existed(projectid, version)
|
210
|
+
tmp = client.project_binary_existed(projectid, version)
|
211
211
|
err "Version '#{version}' already exists." if tmp.include?("true")
|
212
212
|
end
|
213
|
-
|
214
|
-
unless path
|
213
|
+
|
214
|
+
unless path
|
215
215
|
loop{
|
216
216
|
path = ask "Please enter the path of upload war file"
|
217
217
|
if not ((path =~ /\.(war)$/) && (File.exists? path))
|
218
|
-
display "Not war file or path does not exist!"
|
218
|
+
display "Not war file or path does not exist!"
|
219
219
|
path =nil
|
220
220
|
next
|
221
221
|
else
|
222
222
|
break
|
223
223
|
end
|
224
|
-
}
|
224
|
+
}
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
unless version
|
228
228
|
loop{
|
229
229
|
version = ask "Please enter the version"
|
@@ -237,8 +237,8 @@ module PI::Cli::Command
|
|
237
237
|
break
|
238
238
|
end
|
239
239
|
}
|
240
|
-
end
|
241
|
-
|
240
|
+
end
|
241
|
+
|
242
242
|
description = ask "Please enter in the description", :default => nil unless description
|
243
243
|
upload_file = File.new(path, 'rb')
|
244
244
|
manifest = {
|
@@ -246,17 +246,17 @@ module PI::Cli::Command
|
|
246
246
|
:fileWAR => upload_file,
|
247
247
|
:versionName => "#{version}",
|
248
248
|
:description => "#{description}"
|
249
|
-
}
|
249
|
+
}
|
250
250
|
display "Uploading \"#{File.basename(path)}\": ",false
|
251
|
-
|
252
|
-
t = Thread.new do
|
251
|
+
|
252
|
+
t = Thread.new do
|
253
253
|
loop do
|
254
|
-
display '.', false
|
254
|
+
display '.', false
|
255
255
|
sleep (1)
|
256
256
|
break unless t.alive?
|
257
257
|
end
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
client.upload(manifest)
|
261
261
|
Thread.kill(t)
|
262
262
|
display 'OK'.green
|
@@ -271,16 +271,16 @@ module PI::Cli::Command
|
|
271
271
|
unless projectid
|
272
272
|
useproject = choose_project
|
273
273
|
projectid = useproject[:id]
|
274
|
-
end
|
274
|
+
end
|
275
275
|
binary = client.project_binary(projectid)
|
276
|
-
err "No binary!" if binary.nil? || binary.empty?
|
276
|
+
err "No binary!" if binary.nil? || binary.empty?
|
277
277
|
binaryname = ask"Select Binary", :choices => binary.collect { |b| b[:versionName] }, :indexed => true
|
278
278
|
display "Selected Binary: ",false
|
279
|
-
display "#{binaryname}"
|
279
|
+
display "#{binaryname}"
|
280
280
|
binaryid = nil
|
281
281
|
binary.each do |b|
|
282
282
|
binaryid = b[:id].to_s if binaryname == b[:versionName]
|
283
|
-
end
|
283
|
+
end
|
284
284
|
client.delete_binary(binaryid)
|
285
285
|
display 'OK'.green
|
286
286
|
end
|
@@ -294,7 +294,7 @@ module PI::Cli::Command
|
|
294
294
|
unless projectid
|
295
295
|
useproject = choose_project
|
296
296
|
projectid = useproject[:id]
|
297
|
-
end
|
297
|
+
end
|
298
298
|
events = client.project_events(projectid)
|
299
299
|
return display JSON.pretty_generate(events || []) if @options[:json]
|
300
300
|
return display "No Events." if events.empty?
|
@@ -350,21 +350,21 @@ module PI::Cli::Command
|
|
350
350
|
return display JSON.pretty_generate(commits || []) if @options[:json]
|
351
351
|
return display "No Commits" if commits.nil? || commits.empty?
|
352
352
|
commits_table = table do |t|
|
353
|
-
t.headings = 'CommitId', 'Date', 'Comment'
|
353
|
+
t.headings = 'CommitId', 'Date', 'Comment'
|
354
354
|
commits.each do |commit|
|
355
355
|
t << [commit[:commit], commit[:date], commit[:comment]]
|
356
356
|
end
|
357
357
|
end
|
358
358
|
display commits_table
|
359
359
|
end
|
360
|
-
|
361
|
-
private
|
362
|
-
|
360
|
+
|
361
|
+
private
|
362
|
+
|
363
363
|
def project_exists?(projectname)
|
364
364
|
project = client.project_search(projectname)
|
365
|
-
project.nil? ? false : true
|
365
|
+
project.nil? ? false : true
|
366
366
|
end
|
367
|
-
|
368
|
-
|
369
|
-
end
|
367
|
+
|
368
|
+
|
369
|
+
end
|
370
370
|
end
|