vmc 0.4.0.beta.66 → 0.4.0.beta.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,10 @@ module VMC
47
47
  spaced(apps) do |a|
48
48
  display_app(a)
49
49
  end
50
+ elsif quiet?
51
+ apps.each do |a|
52
+ line a.name
53
+ end
50
54
  else
51
55
  table(
52
56
  ["name", "status", "usage", v2? && "plan", "runtime", "url"],
@@ -769,11 +773,6 @@ module VMC
769
773
  IS_UTF8 = !!(ENV["LC_ALL"] || ENV["LC_CTYPE"] || ENV["LANG"])["UTF-8"]
770
774
 
771
775
  def display_app(a)
772
- if quiet?
773
- line a.name
774
- return
775
- end
776
-
777
776
  status = app_status(a)
778
777
 
779
778
  line "#{c(a.name, :name)}: #{status}"
@@ -78,63 +78,68 @@ module VMC
78
78
  end
79
79
 
80
80
  if runtimes
81
- unless quiet?
82
- line
83
- line "runtimes:"
84
- end
81
+ line unless quiet?
85
82
 
86
- indented do
87
- if runtimes.empty? && !quiet?
88
- line "#{d("none")}"
89
- else
90
- spaced(runtimes) do |r|
91
- display_runtime(r)
92
- end
83
+ if runtimes.empty? && !quiet?
84
+ line "#{d("none")}"
85
+ elsif input[:quiet]
86
+ runtimes.each do |r|
87
+ line r.name
93
88
  end
89
+ else
90
+ table(
91
+ %w{runtime description},
92
+ runtimes.sort_by(&:name).collect { |r|
93
+ [c(r.name, :name), r.description]
94
+ })
94
95
  end
95
96
  end
96
97
 
97
98
  if frameworks
98
- unless quiet?
99
- line
100
- line "frameworks:"
101
- end
99
+ line unless quiet?
102
100
 
103
- indented do
104
- if frameworks.empty? && !quiet?
105
- line "#{d("none")}"
106
- else
107
- spaced(frameworks) do |f|
108
- display_framework(f)
109
- end
101
+ if frameworks.empty? && !quiet?
102
+ line "#{d("none")}"
103
+ elsif input[:quiet]
104
+ frameworks.each do |f|
105
+ line f.name
110
106
  end
107
+ else
108
+ table(
109
+ %w{framework description},
110
+ frameworks.sort_by(&:name).collect { |f|
111
+ [c(f.name, :name), f.description]
112
+ })
111
113
  end
112
114
  end
113
115
 
114
116
  if services
115
- unless quiet?
116
- line
117
- line "services:"
118
- end
117
+ line unless quiet?
119
118
 
120
- indented do
121
- if services.empty? && !quiet?
122
- line "#{d("none")}"
123
- else
124
- spaced(services) do |s|
125
- display_service(s)
126
- end
119
+ if services.empty? && !quiet?
120
+ line "#{d("none")}"
121
+ elsif input[:quiet]
122
+ services.each do |s|
123
+ line s.label
127
124
  end
125
+ else
126
+ table(
127
+ ["service", "version", "provider", v2? && "plans", "description"],
128
+ services.sort_by(&:label).collect { |s|
129
+ [ c(s.label, :name),
130
+ s.version,
131
+ s.provider,
132
+ v2? && s.service_plans.collect(&:name).join(", "),
133
+ s.description
134
+ ]
135
+ })
128
136
  end
129
137
  end
130
138
  end
131
139
 
132
140
  desc "Set or display the target cloud, organization, and space"
133
141
  group :start
134
- input :url, :argument => :optional,
135
- :desc => "Target URL to switch to"
136
- input :interactive, :alias => "-i", :type => :boolean,
137
- :desc => "Interactively select organization/space"
142
+ input :url, :argument => :optional, :desc => "Target URL to switch to"
138
143
  input(:organization, :aliases => ["--org", "-o"],
139
144
  :from_given => find_by_name("organization"),
140
145
  :desc => "Organization") { |orgs|
@@ -146,8 +151,7 @@ module VMC
146
151
  ask("Space", :choices => spaces, :display => proc(&:name))
147
152
  }
148
153
  def target
149
- if !input[:interactive] && !input.given?(:url) &&
150
- !input.given?(:organization) && !input.given?(:space)
154
+ if !input.given?(:url) && !input.given?(:organization) && !input.given?(:space)
151
155
  display_target
152
156
  display_org_and_space unless quiet?
153
157
  return
@@ -163,8 +167,7 @@ module VMC
163
167
 
164
168
  return unless v2? && client.logged_in?
165
169
 
166
- if input[:interactive] || input.given?(:organization) ||
167
- input.given?(:space)
170
+ if input.given?(:organization) || input.given?(:space)
168
171
  info = target_info
169
172
 
170
173
  select_org_and_space(input, info)
@@ -197,8 +200,6 @@ module VMC
197
200
  input :username, :alias => "--email", :argument => :optional,
198
201
  :desc => "Account email"
199
202
  input :password, :desc => "Account password"
200
- input :interactive, :alias => "-i", :type => :boolean,
201
- :desc => "Interactively select organization/space"
202
203
  input(:organization, :aliases => ["--org", "-o"],
203
204
  :from_given => find_by_name("organization"),
204
205
  :desc => "Organization") { |orgs|
@@ -255,7 +256,7 @@ module VMC
255
256
  invalidate_client
256
257
 
257
258
  if v2?
258
- line if input[:interactive]
259
+ line if input.interactive?(:organization) || input.interactive?(:space)
259
260
  select_org_and_space(input, info)
260
261
  save_target_info(info)
261
262
  end
@@ -364,60 +365,6 @@ module VMC
364
365
  rescue CFoundry::APIError
365
366
  end
366
367
 
367
- def display_runtime(r)
368
- if quiet?
369
- line r.name
370
- else
371
- line "#{c(r.name, :name)}:"
372
-
373
- indented do
374
- line "description: #{b(r.description)}" if r.description
375
-
376
- # TODO: probably won't have this in final version
377
- line "apps: #{name_list(r.apps)}"
378
- end
379
- end
380
- end
381
-
382
- def display_service(s)
383
- if quiet?
384
- line s.label
385
- else
386
- line "#{c(s.label, :name)}:"
387
-
388
- indented do
389
- line "description: #{s.description}"
390
- line "version: #{s.version}"
391
- line "provider: #{s.provider}"
392
-
393
- if v2?
394
- line "plans:"
395
- indented do
396
- s.service_plans.sort_by(&:name).each do |p|
397
- line "#{c(p.name, :name)}: #{p.description}"
398
- end
399
- end
400
- end
401
- end
402
- end
403
- end
404
-
405
- def display_framework(f)
406
- if quiet?
407
- line f.name
408
- else
409
- line "#{c(f.name, :name)}:"
410
-
411
- indented do
412
- line "description: #{b(f.description)}" if f.description
413
-
414
- # TODO: probably won't show this in final version; just for show
415
- apps = f.apps.collect { |a| c(a.name, :name) }
416
- line "apps: #{apps.empty? ? d("none") : apps.join(", ")}"
417
- end
418
- end
419
- end
420
-
421
368
  def org_valid?(guid, user = client.current_user)
422
369
  return false unless guid
423
370
  client.organization(guid).users.include? user
@@ -435,12 +382,11 @@ module VMC
435
382
  def select_org_and_space(input, info)
436
383
  changed_org = false
437
384
 
438
- if input[:interactive] || input.given?(:organization) || \
439
- !org_valid?(info[:organization])
385
+ if input.given?(:organization) || !org_valid?(info[:organization])
440
386
  orgs = client.organizations
441
387
  fail "No organizations!" if orgs.empty?
442
388
 
443
- if !input[:interactive] && orgs.size == 1 && !input.given?(:organization)
389
+ if orgs.size == 1 && !input.given?(:organization)
444
390
  org = orgs.first
445
391
  else
446
392
  org = input[:organization, orgs.sort_by(&:name)]
@@ -455,16 +401,15 @@ module VMC
455
401
  end
456
402
 
457
403
  # switching org means switching space
458
- if input[:interactive] || changed_org || input.given?(:space) || \
459
- !space_valid?(info[:space])
404
+ if changed_org || input.given?(:space) || !space_valid?(info[:space])
460
405
  spaces = org.spaces
461
406
 
462
407
  fail "No spaces!" if spaces.empty?
463
408
 
464
- if !input[:interactive] && spaces.size == 1 && !input.given?(:space)
409
+ if spaces.size == 1 && !input.given?(:space)
465
410
  space = spaces.first
466
411
  else
467
- line if input[:interactive] && changed_org
412
+ line if changed_org && input.interactive?(:organization)
468
413
  space = input[:space, spaces.sort_by(&:name)]
469
414
  end
470
415
 
@@ -38,25 +38,21 @@ module VMC
38
38
  option :verbose, :alias => "-V", :type => :boolean,
39
39
  :desc => "Print extra information"
40
40
 
41
- option(:force, :alias => "-f", :type => :boolean,
42
- :desc => "Skip interaction when possible") {
43
- input[:script]
44
- }
45
-
46
- option(:quiet, :alias => "-q", :type => :boolean,
47
- :desc => "Simplify output format") {
48
- input[:script]
49
- }
50
-
51
- option(:script, :type => :boolean,
52
- :desc => "Shortcut for --quiet and --force") {
53
- !$stdout.tty?
54
- }
55
-
56
- option(:color, :type => :boolean, :default => true,
57
- :desc => "Use colorful output") {
58
- !input[:quiet]
59
- }
41
+ option :force, :alias => "-f", :type => :boolean,
42
+ :default => proc { input[:script] },
43
+ :desc => "Skip interaction when possible"
44
+
45
+ option :quiet, :alias => "-q", :type => :boolean,
46
+ :default => proc { input[:script] },
47
+ :desc => "Simplify output format"
48
+
49
+ option :script, :type => :boolean,
50
+ :default => proc { !$stdout.tty? },
51
+ :desc => "Shortcut for --quiet and --force"
52
+
53
+ option :color, :type => :boolean,
54
+ :default => proc { !input[:quiet] },
55
+ :desc => "Use colorful output"
60
56
 
61
57
  option :trace, :alias => "-t", :type => :boolean,
62
58
  :desc => "Show API requests and responses"
@@ -17,7 +17,7 @@ module VMC
17
17
  end
18
18
 
19
19
  def start_line(msg)
20
- print " " * @@indentation
20
+ print " " * @@indentation unless quiet?
21
21
  print msg
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.66"
2
+ VERSION = "0.4.0.beta.67"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: -614476860
4
+ hash: 1620813125
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 66
12
- version: 0.4.0.beta.66
11
+ - 67
12
+ version: 0.4.0.beta.67
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-10-15 00:00:00 Z
20
+ date: 2012-10-16 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: json_pure
@@ -265,12 +265,12 @@ dependencies:
265
265
  requirements:
266
266
  - - ~>
267
267
  - !ruby/object:Gem::Version
268
- hash: 71
268
+ hash: 69
269
269
  segments:
270
270
  - 0
271
271
  - 3
272
- - 42
273
- version: 0.3.42
272
+ - 43
273
+ version: 0.3.43
274
274
  type: :runtime
275
275
  version_requirements: *id015
276
276
  - !ruby/object:Gem::Dependency
@@ -297,12 +297,12 @@ dependencies:
297
297
  requirements:
298
298
  - - ~>
299
299
  - !ruby/object:Gem::Version
300
- hash: 21
300
+ hash: 17
301
301
  segments:
302
302
  - 0
303
303
  - 2
304
- - 1
305
- version: 0.2.1
304
+ - 3
305
+ version: 0.2.3
306
306
  type: :runtime
307
307
  version_requirements: *id017
308
308
  - !ruby/object:Gem::Dependency