pi 0.1.33 → 0.1.34

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ class PI::Cli::Runner
24
24
  def parse_options!
25
25
  opts_parser = OptionParser.new do |opts|
26
26
  opts.banner = "\nAvailable options:\n\n"
27
-
27
+
28
28
  # opts.on('--url URL') { |url| @options[:url] = url }
29
29
  opts.on('--user USER') { |user| @options[:user] = user }
30
30
  opts.on('--password PASS') { |pass| @options[:password] = pass }
@@ -63,7 +63,7 @@ class PI::Cli::Runner
63
63
  @args.concat instances_delta_arg
64
64
  self
65
65
  end
66
-
66
+
67
67
  def check_instances_delta!
68
68
  return unless @args
69
69
  instance_args = @args.select { |arg| /^[-]\d+$/ =~ arg } || []
@@ -88,7 +88,7 @@ class PI::Cli::Runner
88
88
  else
89
89
  @exit_status = false
90
90
  if @args.size > args_range.last
91
- usage_error("Invalid arguments for [#{action}]")
91
+ usage_error("Invalid arguments for [#{action}]")
92
92
  # usage_error("Too many arguments for [#{action}]: %s" % [ @args[args_range.last..-1].map{|a| "'#{a}'"}.join(', ') ])
93
93
  else
94
94
  usage_error("Not enough arguments for [#{action}]")
@@ -99,44 +99,44 @@ class PI::Cli::Runner
99
99
  def parse_command!
100
100
  # just return if already set, happends with -v, -h
101
101
  return if @namespace && @action
102
-
102
+
103
103
  # @help_only = false
104
-
105
- verb = @args.shift
104
+
105
+ verb = @args.shift
106
106
  case verb
107
-
107
+
108
108
  ###############################################################################
109
109
  # Users
110
110
  ###############################################################################
111
-
111
+
112
112
  when 'login'
113
- usage('pi login [url] [--user USER] [--password PASS]')
113
+ usage('pi login [env] [--user USER] [--password PASS]')
114
114
  if @args.size == 1
115
115
  set_cmd(:user, :login, 1)
116
116
  else
117
117
  set_cmd(:user, :login)
118
118
  end
119
-
119
+
120
120
  when 'logout'
121
121
  usage('pi logout')
122
122
  set_cmd(:user, :logout)
123
-
123
+
124
124
  when 'info'
125
125
  usage ('pi info')
126
126
  set_cmd(:user, :info)
127
-
127
+
128
128
  when 'user'
129
129
  usage ('pi user')
130
130
  set_cmd(:user, :user)
131
-
131
+
132
132
  when 'targets'
133
133
  usage ('pi targets')
134
134
  set_cmd(:user, :targets)
135
-
135
+
136
136
  when 'password'
137
137
  usage ('pi password [oldpassword] [--password PASS]')
138
138
  set_cmd(:user, :password, @args.size == 1 ? 1 : 0)
139
-
139
+
140
140
  when 'github'
141
141
  usage ('pi github [name] [--email EMAIL] [--password PASS]')
142
142
  if @args.size == 1
@@ -144,7 +144,7 @@ class PI::Cli::Runner
144
144
  else
145
145
  set_cmd(:user, :github)
146
146
  end
147
-
147
+
148
148
  when 'runtimes'
149
149
  usage('pi runtimes')
150
150
  set_cmd(:user, :runtimes)
@@ -152,44 +152,44 @@ class PI::Cli::Runner
152
152
  when 'frameworks'
153
153
  usage('pi frameworks')
154
154
  set_cmd(:user, :frameworks)
155
-
155
+
156
156
  when 'version', 'v'
157
157
  usage('pi version')
158
158
  set_cmd(:misc, :version)
159
-
159
+
160
160
  when 'help'
161
- if @args.size == 0
161
+ if @args.size == 0
162
162
  display_help
163
163
  # break
164
164
  else if @args == ["help"] && @args.size == 1
165
165
  usage('pi help [command]')
166
166
  else
167
- @help_only = true
168
- parse_command!
167
+ @help_only = true
168
+ parse_command!
169
169
  end
170
170
  end
171
-
172
-
171
+
172
+
173
173
  when 'options'
174
174
  @args = @args.unshift('--options')
175
175
  parse_options!
176
-
176
+
177
177
  ###############################################################################
178
178
  # Projects
179
179
  ###############################################################################
180
-
180
+
181
181
  when 'projects'
182
182
  usage('pi projects')
183
183
  set_cmd(:projects, :projects)
184
-
184
+
185
185
  when 'create-project'
186
186
  usage('pi create-project [project]')
187
187
  set_cmd(:projects, :create_project, @args.size == 1 ? 1 : 0)
188
-
188
+
189
189
  when 'delete-project'
190
190
  usage('pi delete-project [projectid]')
191
- set_cmd(:projects, :delete_project, @args.size == 1 ? 1 : 0)
192
-
191
+ set_cmd(:projects, :delete_project, @args.size == 1 ? 1 : 0)
192
+
193
193
  when 'upload'
194
194
  usage('pi upload [projectid] [--path PATH] [--ver VERSION] [--desc DESC]')
195
195
  if @args.size == 1
@@ -197,177 +197,177 @@ class PI::Cli::Runner
197
197
  else
198
198
  set_cmd(:projects, :upload)
199
199
  end
200
-
200
+
201
201
  when 'delete-binary'
202
202
  usage('pi delete-binary [project]')
203
203
  set_cmd(:projects, :delete_binary, @args.size == 1 ? 1 : 0)
204
-
205
- when 'project-events'
204
+
205
+ when 'project-events'
206
206
  usage('pi project-events [projectid]')
207
- set_cmd(:projects, :project_events, @args.size == 1 ? 1 : 0)
208
-
207
+ set_cmd(:projects, :project_events, @args.size == 1 ? 1 : 0)
208
+
209
209
  when 'project-tags'
210
210
  usage('pi project-tags [projectid]')
211
- set_cmd(:projects, :project_tags, @args.size == 1 ? 1 : 0)
212
-
211
+ set_cmd(:projects, :project_tags, @args.size == 1 ? 1 : 0)
212
+
213
213
  when 'project-commits'
214
214
  usage('pi project-commits [projectid]')
215
- set_cmd(:projects, :project_commits, @args.size == 1 ? 1 : 0)
216
-
215
+ set_cmd(:projects, :project_commits, @args.size == 1 ? 1 : 0)
216
+
217
217
  ###############################################################################
218
218
  # Applications
219
219
  ###############################################################################
220
-
220
+
221
221
  when 'apps'
222
222
  usage('pi apps [--projectid ID] [--target TARG]')
223
- set_cmd(:apps, :apps)
224
-
223
+ set_cmd(:apps, :apps)
224
+
225
225
  when 'create-app'
226
226
  usage('pi create-app [appname]')
227
- set_cmd(:apps, :create_app, @args.size == 1 ? 1 : 0)
228
-
229
- when 'delete-app'
227
+ set_cmd(:apps, :create_app, @args.size == 1 ? 1 : 0)
228
+
229
+ when 'delete-app'
230
230
  usage('pi delete-app [appid] or pi delete-app <appname> <--target TARGET>')
231
- set_cmd(:apps, :delete_app, @args.size == 1 ? 1 : 0)
232
-
233
- when 'start-app'
231
+ set_cmd(:apps, :delete_app, @args.size == 1 ? 1 : 0)
232
+
233
+ when 'start-app'
234
234
  usage('pi start-app [appid] or pi start-app <appname> <--target TARGET>')
235
- set_cmd(:apps, :start_app, @args.size == 1 ? 1 : 0)
236
-
237
- when 'stop-app'
235
+ set_cmd(:apps, :start_app, @args.size == 1 ? 1 : 0)
236
+
237
+ when 'stop-app'
238
238
  usage('pi stop-app [appid] [--graceful] or pi stop-app <appname> <--target TARGET> [--graceful]')
239
239
  set_cmd(:apps, :stop_app, @args.size == 1 ? 1 : 0)
240
-
241
- when 'restart-app'
240
+
241
+ when 'restart-app'
242
242
  usage('pi restart-app [appid] [--graceful] or pi restart-app <appname> <--target TARGET> [--graceful]')
243
243
  set_cmd(:apps, :restart_app, @args.size == 1 ? 1 : 0)
244
-
245
- when 'scale-app'
244
+
245
+ when 'scale-app'
246
246
  usage('pi scale-app [appid] [--instance N] or pi scale-app <appname> <--target TARGET> [--instance N]')
247
247
  set_cmd(:apps, :scale_app, @args.size == 1 ? 1 : 0)
248
-
249
- when 'update-app'
248
+
249
+ when 'update-app'
250
250
  usage('pi update-app [appid] [--ver VERSION] [--graceful] or pi update-app <appname> <--target TARGET> [--ver VERSION][--graceful] ')
251
251
  set_cmd(:apps, :update_app, @args.size == 1 ? 1 : 0)
252
-
253
- when 'status'
252
+
253
+ when 'status'
254
254
  usage('pi status-app [appid] or pi status-app <appname> <--target TARGET>')
255
255
  set_cmd(:apps, :status, @args.size == 1 ? 1 : 0)
256
-
257
- when 'app-env'
256
+
257
+ when 'app-env'
258
258
  usage('pi start-app [appid] or pi start-app <appname> <--target TARGET>')
259
259
  set_cmd(:apps, :app_env, @args.size == 1 ? 1 : 0)
260
-
261
- when 'create-env'
260
+
261
+ when 'create-env'
262
262
  usage('pi app-env [appid][--name,--value] or pi app-env <appname> <--target TARGET> [--name,--value]')
263
263
  set_cmd(:apps, :create_env, @args.size == 1 ? 1 : 0)
264
-
265
- when 'delete-env'
264
+
265
+ when 'delete-env'
266
266
  usage('pi delete-env [appid] [--name NAME] or pi delete-env <appname> <--target TARGET> [--name NAME]')
267
267
  set_cmd(:apps, :delete_env, @args.size == 1 ? 1 : 0)
268
-
269
- when 'app-log'
268
+
269
+ when 'app-log'
270
270
  usage('pi app-log [appid] [--instanceid,--file] or pi app-log <appname> <--target TARGET> [--instanceid,--file]')
271
271
  set_cmd(:apps, :app_log, @args.size == 1 ? 1 : 0)
272
-
273
- # when 'app-debug'
272
+
273
+ # when 'app-debug'
274
274
  # usage('pi app-debug [appid] or pi app-log <appname> <--target TARGET>')
275
275
  # set_cmd(:apps, :app_debug, @args.size == 1 ? 1 : 0)
276
-
276
+
277
277
  ###############################################################################
278
278
  # Services
279
279
  ###############################################################################
280
-
281
- when 'app-service'
280
+
281
+ when 'app-service'
282
282
  usage('pi app-service [appid] or pi app-service <appname> <--target TARGET>')
283
- set_cmd(:services, :app_service, @args.size == 1 ? 1 : 0)
284
-
285
- when 'bind-service'
283
+ set_cmd(:services, :app_service, @args.size == 1 ? 1 : 0)
284
+
285
+ when 'bind-service'
286
286
  usage('pi bind-service [appid] [--service SERVICE] or pi bind-service <appname> <--target TARGET> [--service SERVICE]')
287
287
  set_cmd(:services, :bind_service, @args.size == 1 ? 1 : 0)
288
-
289
- when 'unbind-service'
288
+
289
+ when 'unbind-service'
290
290
  usage('pi unbind-service [appid] [--service SERVICE] or pi unbind-service <appname> <--target TARGET> [--service SERVICE]')
291
291
  set_cmd(:services, :unbind_service, @args.size == 1 ? 1 : 0)
292
-
293
- when 'services'
292
+
293
+ when 'services'
294
294
  usage('pi services')
295
295
  set_cmd(:services, :services)
296
-
297
- when 'service'
296
+
297
+ when 'service'
298
298
  usage('pi service [serviceid]')
299
299
  set_cmd(:services, :service, @args.size == 1 ? 1 : 0)
300
-
301
- when 'import-service'
300
+
301
+ when 'import-service'
302
302
  usage('pi import-service [url]')
303
303
  set_cmd(:services, :import_service, @args.size == 1 ? 1 : 0)
304
-
305
- when 'export-service'
304
+
305
+ when 'export-service'
306
306
  usage('pi export-service [serviceid]')
307
- set_cmd(:services, :export_service, @args.size == 1 ? 1 : 0)
308
-
309
- when 'check-service'
307
+ set_cmd(:services, :export_service, @args.size == 1 ? 1 : 0)
308
+
309
+ when 'check-service'
310
310
  usage('pi check-service [serviceid]')
311
- set_cmd(:services, :check_service, @args.size == 1 ? 1 : 0)
312
-
313
- when 'register-service'
311
+ set_cmd(:services, :check_service, @args.size == 1 ? 1 : 0)
312
+
313
+ when 'register-service'
314
314
  usage('pi register-service [serviceid] [--target TARGET]')
315
- set_cmd(:services, :register_service, @args.size == 1 ? 1 : 0)
316
-
317
- when 'deregister-service'
315
+ set_cmd(:services, :register_service, @args.size == 1 ? 1 : 0)
316
+
317
+ when 'deregister-service'
318
318
  usage('pi deregister-service [serviceid] [--target TARGET]')
319
319
  set_cmd(:services, :deregister_service, @args.size == 1 ? 1 : 0)
320
-
321
- when 'delete-service'
320
+
321
+ when 'delete-service'
322
322
  usage('pi delete-service [serviceid]')
323
- set_cmd(:services, :delete_service, @args.size == 1 ? 1 : 0)
324
-
323
+ set_cmd(:services, :delete_service, @args.size == 1 ? 1 : 0)
324
+
325
325
  ###############################################################################
326
326
  # Dns
327
327
  ###############################################################################
328
-
329
- when 'app-dns'
328
+
329
+ when 'app-dns'
330
330
  usage('pi app-dns [appid] or pi app-dns <appname> <--target TARGET>')
331
- set_cmd(:dns, :app_dns, @args.size == 1 ? 1 : 0)
332
-
333
- when 'map-dns'
331
+ set_cmd(:dns, :app_dns, @args.size == 1 ? 1 : 0)
332
+
333
+ when 'map-dns'
334
334
  usage('pi map-dns [appid] [--dns DNS] or pi map-dns <appname> <--target TARGET> [--dns DNS]')
335
335
  set_cmd(:dns, :map_dns, @args.size == 1 ? 1 : 0)
336
-
337
- when 'unmap-dns'
336
+
337
+ when 'unmap-dns'
338
338
  usage('pi unmap-dns [appid] [--dns DNS] or pi unmap-dns <appname> <--target TARGET> [--dns DNS]')
339
339
  set_cmd(:dns, :unmap_dns, @args.size == 1 ? 1 : 0)
340
-
341
- when 'dns'
340
+
341
+ when 'dns'
342
342
  usage('pi dns')
343
343
  set_cmd(:dns, :dns)
344
-
345
- when 'zones'
344
+
345
+ when 'zones'
346
346
  usage('pi zones')
347
347
  set_cmd(:dns, :zones)
348
-
349
- when 'create-dns'
348
+
349
+ when 'create-dns'
350
350
  usage('pi create-dns [dnsname] [--zoneid ID] [--projectid ID] [--desc DESC]')
351
351
  set_cmd(:dns, :create_dns, @args.size == 1 ? 1 : 0)
352
-
353
- when 'delete-dns'
352
+
353
+ when 'delete-dns'
354
354
  usage('pi delete-dns [dnsid]')
355
- set_cmd(:dns, :delete_dns, @args.size == 1 ? 1 : 0)
356
-
357
- when 'register-dns'
355
+ set_cmd(:dns, :delete_dns, @args.size == 1 ? 1 : 0)
356
+
357
+ when 'register-dns'
358
358
  usage('pi register-dns [dnsid] [--target,--continent,--country]')
359
- set_cmd(:dns, :register_dns, @args.size == 1 ? 1 : 0)
360
-
359
+ set_cmd(:dns, :register_dns, @args.size == 1 ? 1 : 0)
360
+
361
361
  when 'dns-records'
362
362
  usage('pi dns-records [dnsid]')
363
- set_cmd(:dns, :dns_records, @args.size == 1 ? 1 : 0)
364
-
365
- when 'deregister-dns'
363
+ set_cmd(:dns, :dns_records, @args.size == 1 ? 1 : 0)
364
+
365
+ when 'deregister-dns'
366
366
  usage('pi deregister-dns [dnsid] [--recordid ID]')
367
- set_cmd(:dns, :deregister_dns, @args.size == 1 ? 1 : 0)
368
-
369
- ###############################################################################
370
-
367
+ set_cmd(:dns, :deregister_dns, @args.size == 1 ? 1 : 0)
368
+
369
+ ###############################################################################
370
+
371
371
  when 'usage'
372
372
  display basic_usage
373
373
  exit(true)
@@ -391,8 +391,8 @@ class PI::Cli::Runner
391
391
  @usage_error
392
392
  end
393
393
 
394
- def run
395
-
394
+ def run
395
+
396
396
  trap('TERM') { print "\nTerminated\n"; exit(false)}
397
397
 
398
398
  parse_options!
@@ -407,7 +407,7 @@ class PI::Cli::Runner
407
407
  # set -o noglob
408
408
  # system('set -o noglob')
409
409
  # Kernel.exec('sudo set -o noglob')
410
- # `set -o noglob`
410
+ # `set -o noglob`
411
411
  parse_command!
412
412
  # system('set +o noglob')
413
413
  # set +o noglob
@@ -431,10 +431,10 @@ class PI::Cli::Runner
431
431
  puts("\n")
432
432
  puts(basic_usage)
433
433
  @exit_status = false
434
- rescue OptionParser::MissingArgument => e
434
+ rescue OptionParser::MissingArgument => e
435
435
  puts(e.message.red)
436
436
  puts("\n")
437
- puts(basic_usage)
437
+ puts(basic_usage)
438
438
  @exit_status = false
439
439
  rescue OptionParser::InvalidArgument => e
440
440
  puts(e.message.red)
@@ -25,7 +25,7 @@ class PI::Cli::Runner
25
25
  Currently available pi commands are:
26
26
 
27
27
  User
28
- login [url] [--user,--password] Login
28
+ login [env] [--user,--password] Login
29
29
  logout Logs current user out of the system
30
30
  info List system information
31
31
  user Display user information
@@ -37,17 +37,17 @@ Currently available pi commands are:
37
37
  version Display version information
38
38
  help [command] Get general help or help on a specific command
39
39
  help options Get help on available options
40
-
40
+
41
41
  Project
42
- projects List created projects
43
- create-project [project] Create a new project
44
- delete-project [projectid] Delete the project
42
+ projects List created projects
43
+ create-project [project] Create a new project
44
+ delete-project [projectid] Delete the project
45
45
  project-events [projectid] List the event info for the project
46
46
  project-tags [projectid] List the tags for the project
47
47
  project-commits [projectid] List the commit log for the project
48
48
  upload [projectid] [--path,--ver,--desc] Upload the war package for java project
49
-
50
- Application
49
+
50
+ Application
51
51
  apps [--projectid,--target] List deployed applications
52
52
  create-app [appname] Create a new application
53
53
  delete-app [appid] Delete the application
@@ -75,7 +75,7 @@ Currently available pi commands are:
75
75
  delete-env <appname> <--target TARGET> [--name NAME] Delete the environment for the application
76
76
  app-log [appid] [--instanceid,--file] List the logs for the application
77
77
  app-log <appname> <--target TARGET> [--instanceid,--file] List the logs for the application
78
-
78
+
79
79
  Service
80
80
  app-service [appid] Display the binded services for the application
81
81
  app-service <appname> <--target TARGET> Display the binded services for the application
@@ -87,17 +87,17 @@ Currently available pi commands are:
87
87
  service [serviceid] List the connection info for the service
88
88
  export-service [serviceid] Export dedicated service url
89
89
  import-service [url] Import dedicated service
90
- check-service [serviceid] Check availability for the service
90
+ check-service [serviceid] Check availability for the service
91
91
  delete-service [serviceid] Delete the service
92
92
  register-service [serviceid] [--target TARGET] Register to target
93
93
  deregister-service [serviceid] [--target TARGET] Deregister to target
94
-
94
+
95
95
  DNS
96
96
  app-dns [appid] Display the mapped urls for the application
97
97
  app-dns <appname> <--target TARGET> Display the mapped urls for the application
98
98
  map-dns [appid] [--dns DNS] Map the urls for the application
99
99
  map-dns <appname> <--target TARGET> [--dns DNS] Map the urls for the application
100
- unmap-dns [appid] [--dns DNS] Unmap the urls for the application
100
+ unmap-dns [appid] [--dns DNS] Unmap the urls for the application
101
101
  unmap-dns <appname> <--target TARGET> [--dns DNS] Unmap the urls for the application
102
102
  dns List the dns
103
103
  zones List the dns zones