vmc 0.4.0.beta.50 → 0.4.0.beta.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -127,6 +127,7 @@ module VMC
127
127
 
128
128
  msg = e.class.name
129
129
  msg << ": #{e}" unless e.to_s.empty?
130
+ msg << "\nFor more information, see #{VMC::CRASH_FILE}"
130
131
  err msg
131
132
  end
132
133
 
@@ -41,6 +41,8 @@ module VMC
41
41
  input :runtime, :desc => "Filter by runtime regexp"
42
42
  input :framework, :desc => "Filter by framework regexp"
43
43
  input :url, :desc => "Filter by url regexp"
44
+ input :one_line, :alias => "-l", :type => :boolean, :default => false,
45
+ :desc => "One line per app; tabular format"
44
46
  def apps
45
47
  if space = input[:space] || client.current_space
46
48
  apps =
@@ -67,8 +69,32 @@ module VMC
67
69
  !app_matches(a, input)
68
70
  end
69
71
 
70
- spaced(apps.sort_by(&:name)) do |a|
71
- display_app(a)
72
+ apps = apps.sort_by(&:name)
73
+
74
+ if input[:one_line]
75
+ rows = apps.collect { |a|
76
+ [ c(a.name, :name),
77
+ app_status(a),
78
+ "#{human_mb(a.memory)} x #{a.total_instances}",
79
+ v2? && (a.production ? "prod" : "dev"),
80
+ a.runtime.name,
81
+ a.url
82
+ ]
83
+ }
84
+
85
+ tabular(
86
+ [ b("name"),
87
+ b("status"),
88
+ b("usage"),
89
+ v2? && b("plan"),
90
+ b("runtime"),
91
+ b("url")
92
+ ],
93
+ *rows)
94
+ else
95
+ spaced(apps) do |a|
96
+ display_app(a)
97
+ end
72
98
  end
73
99
  end
74
100
 
@@ -322,7 +348,7 @@ module VMC
322
348
  input(:memory, :desc => "Memory limit") { |default|
323
349
  ask("Memory Limit", :choices => memory_choices(default),
324
350
  :allow_other => true,
325
- :default => human_size(default * 1024 * 1024, 0))
351
+ :default => human_mb(default))
326
352
  }
327
353
  input :plan, :default => "D100",
328
354
  :desc => "Application plan (e.g. D100, P200)"
@@ -521,11 +547,14 @@ module VMC
521
547
  stats = info[:stats]
522
548
  usage = stats[:usage]
523
549
  line "instance #{c("\##{idx}", :instance)}:"
524
-
525
550
  indented do
526
- line "cpu: #{percentage(usage[:cpu])} of #{b(stats[:cores])} cores"
527
- line "memory: #{usage(usage[:mem] * 1024, stats[:mem_quota])}"
528
- line "disk: #{usage(usage[:disk], stats[:disk_quota])}"
551
+ if usage
552
+ line "cpu: #{percentage(usage[:cpu])} of #{b(stats[:cores])} cores"
553
+ line "memory: #{usage(usage[:mem] * 1024, stats[:mem_quota])}"
554
+ line "disk: #{usage(usage[:disk], stats[:disk_quota])}"
555
+ else
556
+ line c("stats unavailable (not running?)", :bad)
557
+ end
529
558
  end
530
559
  end
531
560
  end
@@ -747,7 +776,7 @@ module VMC
747
776
  indented do
748
777
  line "platform: #{b(a.framework.name)} on #{b(a.runtime.name)}"
749
778
 
750
- start_line "usage: #{b(human_size(a.memory * 1024 * 1024, 0))}"
779
+ start_line "usage: #{b(human_mb(a.memory))}"
751
780
  print " #{d(IS_UTF8 ? "\xc3\x97" : "x")} #{b(a.total_instances)}"
752
781
  print " instance#{a.total_instances == 1 ? "" : "s"}"
753
782
 
@@ -1108,6 +1137,10 @@ module VMC
1108
1137
  format("%.#{precision}fB", num)
1109
1138
  end
1110
1139
 
1140
+ def human_mb(num)
1141
+ human_size(num * 1024 * 1024, 0)
1142
+ end
1143
+
1111
1144
  def target_base
1112
1145
  client.target.sub(/^https?:\/\/([^\.]+\.)?(.+)\/?/, '\2')
1113
1146
  end
@@ -1121,7 +1154,7 @@ module VMC
1121
1154
  mem = 64
1122
1155
  choices = []
1123
1156
  until mem > available
1124
- choices << human_size(mem * 1024 * 1024, precision = 0)
1157
+ choices << human_mb(mem)
1125
1158
  mem *= 2
1126
1159
  end
1127
1160
 
@@ -22,7 +22,7 @@ module VMC
22
22
  client.current_organization
23
23
  }
24
24
  input :full, :type => :boolean,
25
- :desc => "Show full information for appspaces"
25
+ :desc => "Show full information for spaces, domains, etc."
26
26
  def org
27
27
  org = input[:organization]
28
28
 
@@ -229,7 +229,9 @@ module VMC
229
229
 
230
230
  authenticated = false
231
231
  failed = false
232
- until authenticated
232
+ remaining_attempts = 3
233
+ until authenticated || remaining_attempts <= 0
234
+ remaining_attempts -= 1
233
235
  unless force?
234
236
  ask_prompts(credentials, prompts)
235
237
  end
@@ -41,5 +41,45 @@ module VMC
41
41
  num += 1
42
42
  end
43
43
  end
44
+
45
+ def tabular(*rows)
46
+ spacings = []
47
+ rows.each do |row|
48
+ row.each.with_index do |col, i|
49
+ next unless col
50
+
51
+ width = text_width(col)
52
+
53
+ if !spacings[i] || width > spacings[i]
54
+ spacings[i] = width
55
+ end
56
+ end
57
+ end
58
+
59
+ columns = spacings.size
60
+ rows.each do |row|
61
+ row.each.with_index do |col, i|
62
+ next unless col
63
+
64
+ start_line justify(col, spacings[i])
65
+ print " " unless i + 1 == columns
66
+ end
67
+
68
+ line
69
+ end
70
+ end
71
+
72
+ def trim_escapes(str)
73
+ str.gsub(/\e\[\d+m/, "")
74
+ end
75
+
76
+ def text_width(str)
77
+ trim_escapes(str).size
78
+ end
79
+
80
+ def justify(str, width)
81
+ trimmed = trim_escapes(str)
82
+ str.ljust(width + (str.size - trimmed.size))
83
+ end
44
84
  end
45
85
  end
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.50"
2
+ VERSION = "0.4.0.beta.51"
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: -1152463690
4
+ hash: 260162495
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 50
12
- version: 0.4.0.beta.50
11
+ - 51
12
+ version: 0.4.0.beta.51
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-09-12 00:00:00 Z
20
+ date: 2012-09-13 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: json_pure