pi 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- data/README +367 -404
- data/lib/cli.rb +1 -0
- data/lib/cli/choose_helper.rb +123 -25
- data/lib/cli/commands/apps.rb +241 -303
- data/lib/cli/commands/dns.rb +38 -73
- data/lib/cli/commands/projects.rb +179 -160
- data/lib/cli/commands/services.rb +55 -80
- data/lib/cli/commands/user.rb +26 -10
- data/lib/cli/interact_helper.rb +538 -0
- data/lib/cli/runner.rb +77 -53
- data/lib/cli/usage.rb +55 -39
- data/lib/cli/version.rb +1 -1
- data/lib/pi/client.rb +92 -77
- data/lib/pi/const.rb +2 -0
- metadata +5 -5
- data/lib/cli/commands/admin.rb +0 -19
data/lib/cli/commands/dns.rb
CHANGED
@@ -1,37 +1,13 @@
|
|
1
|
-
require "interact"
|
2
1
|
module PI::Cli::Command
|
3
2
|
class Dns < Base
|
4
3
|
include PI::Cli::ChooseHelper
|
5
|
-
include
|
4
|
+
include PI::Cli::InteractHelper
|
6
5
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
appname = useapp[:name]
|
13
|
-
end
|
14
|
-
dns = client.usable_dns(appname)
|
15
|
-
return display JSON.pretty_generate(dns) if @options[:json]
|
16
|
-
return display "No Dns" if dns.nil? || dns.empty?
|
17
|
-
dns.sort! {|a, b| a[:name] <=> b[:name] }
|
18
|
-
dns_table = table do |t|
|
19
|
-
t.headings = 'Name'
|
20
|
-
dns.each do |s|
|
21
|
-
t << [s[:name]]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
display dns_table
|
25
|
-
end
|
26
|
-
|
27
|
-
def app_dns(appname=nil)
|
28
|
-
unless appname
|
29
|
-
useproject = choose_project
|
30
|
-
projectid = useproject[:id]
|
31
|
-
useapp = choose_app(projectid)
|
32
|
-
appname = useapp[:name]
|
33
|
-
end
|
34
|
-
dns = client.app_dns(appname)
|
6
|
+
def app_dns(appid_or_appname=nil)
|
7
|
+
client.check_login_status
|
8
|
+
app = choose_app_help_target_not_all(appid_or_appname)
|
9
|
+
|
10
|
+
dns = client.app_dns(app[:id])
|
35
11
|
return display JSON.pretty_generate(dns) if @options[:json]
|
36
12
|
return display "No DNS!" if dns.nil? || dns.empty?
|
37
13
|
dns_table = table do |t|
|
@@ -43,26 +19,21 @@ module PI::Cli::Command
|
|
43
19
|
display dns_table
|
44
20
|
end
|
45
21
|
|
46
|
-
def map_dns(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
useapp = choose_app(projectid)
|
51
|
-
appname = useapp[:name]
|
52
|
-
end
|
53
|
-
app = client.app_get_byname(appname)
|
54
|
-
err "The application is not found! App name :#{appname}" unless (appname == app[:name] ? true : false)
|
55
|
-
|
56
|
-
dns = client.usable_dns(appname)
|
22
|
+
def map_dns(appid_or_appname=nil)
|
23
|
+
client.check_login_status
|
24
|
+
app = choose_app_help_target_not_all(appid_or_appname)
|
25
|
+
dns = client.usable_dns(app[:id])
|
57
26
|
err "No usable dns!" if dns.nil? || dns.empty?
|
58
27
|
choices = Array.new
|
59
28
|
dns.each do |s|
|
60
29
|
choices << s[:name]
|
61
30
|
end
|
62
|
-
manifest =
|
63
|
-
manifest = manifest.to_a
|
31
|
+
manifest = asks "Select dns, indexed list?", :choices => choices, :indexed => true
|
64
32
|
display "Selected dns: ",false
|
65
|
-
|
33
|
+
manifest.each do |m|
|
34
|
+
display "#{m} ",false
|
35
|
+
end
|
36
|
+
display "\n"
|
66
37
|
display "Mapping dns: ",false
|
67
38
|
|
68
39
|
t = Thread.new do
|
@@ -73,47 +44,41 @@ module PI::Cli::Command
|
|
73
44
|
end
|
74
45
|
end
|
75
46
|
|
76
|
-
client.map_dns(
|
47
|
+
client.map_dns(app[:id],manifest)
|
77
48
|
Thread.kill(t)
|
78
49
|
display "OK".green
|
79
50
|
end
|
80
51
|
|
81
|
-
def unmap_dns(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
app = client.app_get_byname(appname)
|
89
|
-
err "The application is not found! App name :#{appname}" unless (appname == app[:name] ? true : false)
|
90
|
-
dns = client.app_dns(appname)
|
91
|
-
err "No mapped dns!" if dns.nil? || dns.empty?
|
92
|
-
usedns = nil
|
93
|
-
choose do |menu|
|
94
|
-
display "=============DNS============"
|
95
|
-
menu.prompt = "Select DNS: "
|
96
|
-
menu.select_by = :index_or_name
|
97
|
-
dns.each do |d|
|
98
|
-
menu.choice("#{d}") { usedns = d }
|
99
|
-
end
|
100
|
-
end
|
52
|
+
def unmap_dns(appid_or_appname=nil)
|
53
|
+
client.check_login_status
|
54
|
+
app = choose_app_help_target_not_all(appid_or_appname)
|
55
|
+
dns = client.app_dns(app[:id])
|
56
|
+
err "No mapped dns!" if dns.nil? || dns.empty?
|
57
|
+
urls = asks "Select DNS", :choices => dns, :indexed => true
|
101
58
|
display "Selected DNS: ",false
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
59
|
+
urls.each do |m|
|
60
|
+
display "#{m} ",false
|
61
|
+
end
|
62
|
+
display "\n"
|
63
|
+
urls.each do |url|
|
64
|
+
do_unmap_dns(app[:id], url)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def do_unmap_dns(appid, url)
|
71
|
+
display "Unmapping dns '#{url}': ",false
|
106
72
|
t = Thread.new do
|
107
73
|
loop do
|
108
74
|
display '.', false
|
109
75
|
sleep (1)
|
110
76
|
break unless t.alive?
|
111
77
|
end
|
112
|
-
end
|
113
|
-
|
114
|
-
client.unmap_dns(appname,manifest)
|
78
|
+
end
|
79
|
+
client.unmap_dns(appid, url)
|
115
80
|
Thread.kill(t)
|
116
|
-
display "OK".green
|
81
|
+
display "OK".green
|
117
82
|
end
|
118
83
|
|
119
84
|
end
|
@@ -2,141 +2,131 @@ require 'digest/sha1'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'tmpdir'
|
5
|
-
require 'set'
|
6
5
|
|
7
6
|
module PI::Cli::Command
|
8
7
|
|
9
8
|
class Projects < Base
|
10
9
|
include PI::Cli::ChooseHelper
|
10
|
+
include PI::Cli::InteractHelper
|
11
11
|
|
12
12
|
def projects
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
client.check_login_status
|
14
|
+
user = client.user_info
|
15
|
+
proj_sum = client.project_sum
|
16
|
+
total_proj = Integer(proj_sum[1])
|
17
|
+
return display "No Projects" if total_proj == 0
|
18
|
+
pageNum = -1
|
19
|
+
numPerPage = -1
|
20
|
+
if total_proj >= 50
|
21
|
+
puts "Total projects: #{total_proj}."
|
22
|
+
numPerPage = nil
|
23
|
+
loop{
|
24
|
+
numPerPage = ask "Number per page"
|
25
|
+
if not numPerPage =~ /^[1-9]\d*$/
|
26
|
+
display "Invalid Number! Please input number from 1 to #{total_proj}"
|
27
|
+
numPerPage =nil
|
28
|
+
next
|
29
|
+
else
|
30
|
+
break
|
31
|
+
end
|
32
|
+
}
|
33
|
+
numPerPage = numPerPage.to_i
|
34
|
+
maxpage = (total_proj.to_f/numPerPage).ceil
|
35
|
+
loop{
|
36
|
+
pageNum = ask "Page number"
|
37
|
+
if not pageNum =~ /^[1-9]\d*$/
|
38
|
+
display "Invalid Number! Please input number from 1 to #{maxpage}"
|
39
|
+
pageNum =nil
|
40
|
+
next
|
41
|
+
else
|
42
|
+
break
|
43
|
+
end
|
44
|
+
}
|
45
|
+
pageNum = pageNum.to_i
|
46
|
+
end
|
47
|
+
projects = client.projects(pageNum, numPerPage)
|
48
|
+
return display "No Projects" if projects.nil? || projects.empty?
|
32
49
|
return display JSON.pretty_generate(projects) if @options[:json]
|
33
|
-
return display "No Projects" if projects.nil? || projects.empty?
|
34
50
|
projects.sort! {|a, b| a[:name] <=> b[:name] }
|
35
51
|
display "\n"
|
36
52
|
projects_table = table do |t|
|
37
|
-
t.headings = 'Name', 'Runtime', 'Framework', 'Git Type','GitUrl', '
|
53
|
+
t.headings = 'Name', 'Runtime', 'Framework', 'Git Type','GitUrl', 'Description'
|
38
54
|
projects.each do |project|
|
39
|
-
t << [project[:name], project[:runtime]
|
55
|
+
t << [project[:name], project[:runtime], project[:framework], project[:repositoryType], project[:gitUrl], project[:description]]
|
40
56
|
end
|
41
57
|
end
|
42
58
|
display projects_table
|
43
59
|
end
|
44
60
|
|
45
|
-
def create_project(
|
61
|
+
def create_project(project=nil)
|
62
|
+
client.check_login_status
|
46
63
|
loop{
|
47
|
-
unless
|
48
|
-
|
49
|
-
err "Project Name required." if
|
64
|
+
unless project
|
65
|
+
project = ask "Project Name"
|
66
|
+
err "Project Name required." if project.nil? || project.empty?
|
50
67
|
end
|
51
|
-
if
|
52
|
-
display "
|
53
|
-
|
68
|
+
if not check_name_valid?(project)
|
69
|
+
display "Invalid project name '#{project}'."
|
70
|
+
project =nil
|
54
71
|
next
|
55
|
-
else
|
72
|
+
else if project_exists?(project)
|
73
|
+
display "Project '#{project}' already exists."
|
74
|
+
project =nil
|
75
|
+
next
|
76
|
+
else
|
56
77
|
break
|
78
|
+
end
|
57
79
|
end
|
58
|
-
}
|
80
|
+
}
|
59
81
|
|
60
|
-
runtime = nil
|
61
82
|
runtimes = client.runtimes
|
62
|
-
|
63
|
-
|
64
|
-
menu.prompt = "Select Runtime: "
|
65
|
-
menu.select_by = :index_or_name
|
66
|
-
runtimes.each do |rt|
|
67
|
-
menu.choice(rt) { runtime = rt }
|
68
|
-
end
|
69
|
-
end
|
83
|
+
err "No Runtimes" if runtimes.nil? || runtimes.empty?
|
84
|
+
runtime = ask "Select Runtime", :choices => runtimes, :indexed => true
|
70
85
|
display "Selected Runtime: ",false
|
71
|
-
display "#{runtime}"
|
86
|
+
display "#{runtime}"
|
72
87
|
|
73
|
-
framework = nil
|
74
88
|
frameworks = client.frameworks(runtime)
|
75
89
|
err "No Frameworks" if frameworks.nil? || frameworks.empty?
|
76
|
-
|
77
|
-
display "=============Frameworks============"
|
78
|
-
menu.prompt = "Select Framework: "
|
79
|
-
menu.select_by = :index_or_name
|
80
|
-
frameworks.each do |fk|
|
81
|
-
menu.choice(fk) { framework = fk }
|
82
|
-
end
|
83
|
-
end
|
90
|
+
framework = ask "Select Framework", :choices => frameworks, :indexed => true
|
84
91
|
display "Selected Framework: ",false
|
85
|
-
display "#{framework}"
|
92
|
+
display "#{framework}"
|
86
93
|
|
87
|
-
description = ask "Please enter in the description"
|
94
|
+
description = ask "Please enter in the description", :default => nil unless description
|
88
95
|
|
89
96
|
github_info = client.github_info
|
90
97
|
|
91
98
|
if github_info[:name].empty?
|
92
99
|
manifest = {
|
93
|
-
:name => "#{
|
100
|
+
:name => "#{project}",
|
94
101
|
:runtime => "#{runtime}",
|
95
102
|
:framework => "#{framework}",
|
96
103
|
:description => "#{description}"
|
97
104
|
}
|
98
|
-
else
|
99
|
-
repositoryType = nil
|
105
|
+
else
|
100
106
|
repositoryTypes =["cloudpi","github"]
|
101
|
-
|
102
|
-
display "=============Repository Types============"
|
103
|
-
menu.prompt = "Select Repository Type: "
|
104
|
-
menu.select_by = :index_or_name
|
105
|
-
repositoryTypes.each do |rt|
|
106
|
-
menu.choice(rt) { repositoryType = rt }
|
107
|
-
end
|
108
|
-
end
|
107
|
+
repositoryType = ask "Select Repository Type", :choices => repositoryTypes, :indexed => true
|
109
108
|
display "Selected Repository Type: ",false
|
110
|
-
display "#{repositoryType}"
|
109
|
+
display "#{repositoryType}"
|
111
110
|
|
112
111
|
if repositoryType == "github"
|
113
|
-
isNew =nil
|
114
112
|
isNew = "yes"
|
115
|
-
publishType = nil
|
116
113
|
publishTypes =["public","private"]
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
menu.select_by = :index_or_name
|
121
|
-
publishTypes.each do |pt|
|
122
|
-
menu.choice(pt) { publishType = pt }
|
123
|
-
end
|
114
|
+
publishType = ask "Select Publish Type", :choices => publishTypes, :indexed => true
|
115
|
+
display "Selected publish Type: ",false
|
116
|
+
display "#{publishType}"
|
124
117
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
:repositoryType => "#{repositoryType}",
|
134
|
-
:isNew => "#{isNew}",
|
135
|
-
:publishType => "#{publishType}"
|
118
|
+
manifest = {
|
119
|
+
:name => "#{project}",
|
120
|
+
:runtime => "#{runtime}",
|
121
|
+
:framework => "#{framework}",
|
122
|
+
:description => "#{description}",
|
123
|
+
:repositoryType => "#{repositoryType}",
|
124
|
+
:isNew => "#{isNew}",
|
125
|
+
:publishType => "#{publishType}"
|
136
126
|
}
|
137
127
|
end
|
138
128
|
|
139
|
-
display "Creating project \"#{
|
129
|
+
display "Creating project \"#{project}\": ",false
|
140
130
|
|
141
131
|
t = Thread.new do
|
142
132
|
loop do
|
@@ -146,17 +136,18 @@ module PI::Cli::Command
|
|
146
136
|
end
|
147
137
|
end
|
148
138
|
|
149
|
-
client.create_project(
|
139
|
+
client.create_project(project, manifest)
|
150
140
|
Thread.kill(t)
|
151
141
|
display "OK".green
|
152
142
|
end
|
153
143
|
|
154
|
-
def delete_project(
|
155
|
-
|
144
|
+
def delete_project(project=nil)
|
145
|
+
client.check_login_status
|
146
|
+
unless project
|
156
147
|
useproject = choose_project
|
157
|
-
|
148
|
+
project = useproject[:name]
|
158
149
|
end
|
159
|
-
display "Deleting project \"#{
|
150
|
+
display "Deleting project \"#{project}\": ",false
|
160
151
|
|
161
152
|
t = Thread.new do
|
162
153
|
loop do
|
@@ -166,35 +157,48 @@ module PI::Cli::Command
|
|
166
157
|
end
|
167
158
|
end
|
168
159
|
|
169
|
-
client.delete_project(
|
160
|
+
client.delete_project(project)
|
170
161
|
Thread.kill(t)
|
171
162
|
display 'OK'.green
|
172
163
|
end
|
173
164
|
|
174
|
-
def upload(
|
175
|
-
|
176
|
-
|
165
|
+
def upload(project=nil)
|
166
|
+
client.check_login_status
|
167
|
+
path = @options[:path]
|
168
|
+
if path
|
169
|
+
err "Not war file or path does not exist!" if not ((path =~ /\.(war)$/) && (File.exists? path))
|
170
|
+
end
|
171
|
+
version = @options[:ver]
|
172
|
+
description = @options[:desc]
|
177
173
|
projects = client.projects
|
178
174
|
err "No Projects" if projects.nil? || projects.empty?
|
179
|
-
java_projects = projects.delete_if{ |p| p[:runtime] =~ /^(ruby)/i}
|
175
|
+
java_projects = projects.delete_if{ |p| p[:runtime] =~ /^(ruby)/i}
|
180
176
|
java_projects.sort! {|a, b| a[:name] <=> b[:name] }
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
177
|
+
if project
|
178
|
+
flag = nil
|
179
|
+
java_projects.each do |j|
|
180
|
+
flag = true if project == j[:name]
|
181
|
+
end
|
182
|
+
err "The project is not found or not a java project! Project name :#{project}" unless flag
|
183
|
+
else
|
184
|
+
project_choices = Array.new
|
185
|
+
java_projects.each do |p|
|
186
|
+
project_choices << p[:name]
|
187
|
+
end
|
188
|
+
project = ask "Select Project", :choices => project_choices, :indexed => true
|
189
|
+
display "Selected Project: ",false
|
190
|
+
display "#{project}"
|
188
191
|
end
|
189
|
-
|
190
|
-
|
192
|
+
project = client.project_search(project)
|
193
|
+
project = project[:name]
|
194
|
+
|
195
|
+
if version
|
196
|
+
tmp = client.project_binary_existed(project,version)
|
197
|
+
err "Version '#{version}' already exists." if tmp.include?("true")
|
191
198
|
end
|
192
|
-
|
193
|
-
version = ask "Please enter the version"
|
194
|
-
description = ask "Please enter in the description"
|
195
199
|
|
196
|
-
path
|
197
|
-
|
200
|
+
unless path
|
201
|
+
loop{
|
198
202
|
path = ask "Please enter the path of upload war file"
|
199
203
|
if not ((path =~ /\.(war)$/) && (File.exists? path))
|
200
204
|
display "Not war file or path does not exist!"
|
@@ -203,13 +207,29 @@ module PI::Cli::Command
|
|
203
207
|
else
|
204
208
|
break
|
205
209
|
end
|
206
|
-
|
207
|
-
|
210
|
+
}
|
211
|
+
end
|
212
|
+
|
213
|
+
unless version
|
214
|
+
loop{
|
215
|
+
version = ask "Please enter the version"
|
216
|
+
tmp = client.project_binary_existed(project,version)
|
217
|
+
if tmp.include?("true")
|
218
|
+
display "Version '#{version}' already exists."
|
219
|
+
version =nil
|
220
|
+
next
|
221
|
+
else
|
222
|
+
break
|
223
|
+
end
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
description = ask "Please enter in the description", :default => nil unless description
|
208
228
|
upload_file = File.new(path, 'rb')
|
209
229
|
manifest = {
|
210
|
-
:projectName => "#{
|
230
|
+
:projectName => "#{project}",
|
211
231
|
:fileWAR => upload_file,
|
212
|
-
:versionName => "#{version
|
232
|
+
:versionName => "#{version}",
|
213
233
|
:description => "#{description}"
|
214
234
|
}
|
215
235
|
display "Uploading \"#{File.basename(path)}\": ",false
|
@@ -227,12 +247,36 @@ module PI::Cli::Command
|
|
227
247
|
display 'OK'.green
|
228
248
|
end
|
229
249
|
|
230
|
-
def
|
231
|
-
|
250
|
+
def delete_binary(project=nil)
|
251
|
+
client.check_login_status
|
252
|
+
unless project
|
232
253
|
useproject = choose_project
|
233
|
-
|
234
|
-
end
|
235
|
-
|
254
|
+
project = useproject[:name]
|
255
|
+
end
|
256
|
+
binary = client.project_binary(project)
|
257
|
+
err "No binary!" if binary.nil? || binary.empty?
|
258
|
+
choices = Array.new
|
259
|
+
binary.each do |b|
|
260
|
+
choices << b[:versionName]
|
261
|
+
end
|
262
|
+
binaryname = ask"Select Binary", :choices => choices, :indexed => true
|
263
|
+
display "Selected Binary: ",false
|
264
|
+
display "#{binaryname}"
|
265
|
+
binaryid = nil
|
266
|
+
binary.each do |b|
|
267
|
+
binaryid = b[:id].to_s if binaryname == b[:versionName]
|
268
|
+
end
|
269
|
+
client.delete_binary(binaryid)
|
270
|
+
display 'OK'.green
|
271
|
+
end
|
272
|
+
|
273
|
+
def project_events(project=nil)
|
274
|
+
client.check_login_status
|
275
|
+
unless project
|
276
|
+
useproject = choose_project
|
277
|
+
project = useproject[:name]
|
278
|
+
end
|
279
|
+
events = client.project_events(project)
|
236
280
|
return display JSON.pretty_generate(events || []) if @options[:json]
|
237
281
|
return display "No Events." if events.empty?
|
238
282
|
events_table = table do |t|
|
@@ -244,12 +288,13 @@ module PI::Cli::Command
|
|
244
288
|
display events_table
|
245
289
|
end
|
246
290
|
|
247
|
-
def project_tags(
|
248
|
-
|
291
|
+
def project_tags(project=nil)
|
292
|
+
client.check_login_status
|
293
|
+
unless project
|
249
294
|
useproject = choose_project
|
250
|
-
|
295
|
+
project = useproject[:name]
|
251
296
|
end
|
252
|
-
tags ||= client.project_tags(
|
297
|
+
tags ||= client.project_tags(project)
|
253
298
|
return display JSON.pretty_generate(tags || []) if @options[:json]
|
254
299
|
return display "No Tags." if tags.size == 0
|
255
300
|
tags_table = table do |t|
|
@@ -260,28 +305,20 @@ module PI::Cli::Command
|
|
260
305
|
display tags_table
|
261
306
|
end
|
262
307
|
|
263
|
-
def project_commits(
|
264
|
-
|
308
|
+
def project_commits(project=nil)
|
309
|
+
client.check_login_status
|
310
|
+
unless project
|
265
311
|
useproject = choose_project
|
266
|
-
|
312
|
+
project = useproject[:name]
|
267
313
|
end
|
268
|
-
|
269
|
-
tags = client.project_tags(projectname)
|
314
|
+
tags = client.project_tags(project)
|
270
315
|
return display JSON.pretty_generate(tags || []) if @options[:json]
|
271
|
-
display "\n"
|
272
316
|
return display "No Commits" if tags.nil? || tags.empty?
|
273
|
-
|
274
|
-
display "=============Tag======="
|
275
|
-
menu.prompt = "Select Tag: "
|
276
|
-
menu.select_by = :index_or_name
|
277
|
-
tags.each do |t|
|
278
|
-
menu.choice(t) { tag = t}
|
279
|
-
end
|
280
|
-
end
|
317
|
+
tag = ask "Select Tag", :choices => tags, :indexed => true
|
281
318
|
display "Selected Tag: ",false
|
282
|
-
display "#{tag}"
|
319
|
+
display "#{tag}"
|
283
320
|
|
284
|
-
commits = client.project_commits(
|
321
|
+
commits = client.project_commits(project,tag)
|
285
322
|
commits.sort! {|a, b| a[:date] <=> b[:date] }
|
286
323
|
return display JSON.pretty_generate(commits || []) if @options[:json]
|
287
324
|
return display "No Commits" if commits.nil? || commits.empty?
|
@@ -293,32 +330,14 @@ module PI::Cli::Command
|
|
293
330
|
end
|
294
331
|
display commits_table
|
295
332
|
end
|
296
|
-
|
297
|
-
def project_apps(projectname=nil)
|
298
|
-
unless projectname
|
299
|
-
useproject = choose_project
|
300
|
-
projectname = useproject[:name]
|
301
|
-
end
|
302
|
-
apps = client.project_apps(projectname)
|
303
|
-
return display JSON.pretty_generate(apps || []) if @options[:json]
|
304
|
-
return display "No applications" if apps.nil? || apps.empty?
|
305
|
-
|
306
|
-
apps.sort! {|a, b| a[:name] <=> b[:name] }
|
307
|
-
apps_table = table do |t|
|
308
|
-
t.headings = 'Target', 'AppName', 'URL', 'Tag', 'Status', 'Instances'
|
309
|
-
apps.each do |app|
|
310
|
-
t << [app[:targetName], app[:name], app[:url], app[:tag], app[:status], app[:instances]]
|
311
|
-
end
|
312
|
-
end
|
313
|
-
display apps_table
|
314
|
-
end
|
315
333
|
|
316
334
|
private
|
317
335
|
|
318
336
|
def project_exists?(projectname)
|
319
|
-
project = client.
|
320
|
-
|
337
|
+
project = client.project_search(projectname)
|
338
|
+
project[:id] != 0 ? true : false
|
321
339
|
end
|
340
|
+
|
322
341
|
|
323
342
|
end
|
324
343
|
end
|