af 0.3.22 → 0.5.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +14 -6
  2. data/LICENSE +1277 -24
  3. data/Rakefile +24 -87
  4. data/bin/af +7 -2
  5. data/lib/af/version.rb +3 -0
  6. data/lib/vmc.rb +7 -2
  7. data/lib/vmc/cli.rb +475 -0
  8. data/lib/vmc/cli/app/app.rb +45 -0
  9. data/lib/vmc/cli/app/apps.rb +105 -0
  10. data/lib/vmc/cli/app/base.rb +82 -0
  11. data/lib/vmc/cli/app/crashes.rb +46 -0
  12. data/lib/vmc/cli/app/delete.rb +95 -0
  13. data/lib/vmc/cli/app/deprecated.rb +11 -0
  14. data/lib/vmc/cli/app/env.rb +78 -0
  15. data/lib/vmc/cli/app/files.rb +137 -0
  16. data/lib/vmc/cli/app/health.rb +26 -0
  17. data/lib/vmc/cli/app/instances.rb +53 -0
  18. data/lib/vmc/cli/app/logs.rb +76 -0
  19. data/lib/vmc/cli/app/push.rb +107 -0
  20. data/lib/vmc/cli/app/push/create.rb +150 -0
  21. data/lib/vmc/cli/app/push/interactions.rb +100 -0
  22. data/lib/vmc/cli/app/push/sync.rb +64 -0
  23. data/lib/vmc/cli/app/rename.rb +39 -0
  24. data/lib/vmc/cli/app/restart.rb +20 -0
  25. data/lib/vmc/cli/app/scale.rb +71 -0
  26. data/lib/vmc/cli/app/start.rb +93 -0
  27. data/lib/vmc/cli/app/stats.rb +67 -0
  28. data/lib/vmc/cli/app/stop.rb +27 -0
  29. data/lib/vmc/cli/domain/base.rb +12 -0
  30. data/lib/vmc/cli/domain/domains.rb +40 -0
  31. data/lib/vmc/cli/domain/map.rb +55 -0
  32. data/lib/vmc/cli/domain/unmap.rb +56 -0
  33. data/lib/vmc/cli/help.rb +16 -0
  34. data/lib/vmc/cli/interactive.rb +105 -0
  35. data/lib/vmc/cli/organization/base.rb +14 -0
  36. data/lib/vmc/cli/organization/create.rb +32 -0
  37. data/lib/vmc/cli/organization/delete.rb +73 -0
  38. data/lib/vmc/cli/organization/org.rb +45 -0
  39. data/lib/vmc/cli/organization/orgs.rb +35 -0
  40. data/lib/vmc/cli/organization/rename.rb +36 -0
  41. data/lib/vmc/cli/route/base.rb +12 -0
  42. data/lib/vmc/cli/route/map.rb +80 -0
  43. data/lib/vmc/cli/route/routes.rb +26 -0
  44. data/lib/vmc/cli/route/unmap.rb +94 -0
  45. data/lib/vmc/cli/service/base.rb +8 -0
  46. data/lib/vmc/cli/service/bind.rb +44 -0
  47. data/lib/vmc/cli/service/create.rb +126 -0
  48. data/lib/vmc/cli/service/delete.rb +86 -0
  49. data/lib/vmc/cli/service/rename.rb +35 -0
  50. data/lib/vmc/cli/service/service.rb +42 -0
  51. data/lib/vmc/cli/service/services.rb +115 -0
  52. data/lib/vmc/cli/service/unbind.rb +38 -0
  53. data/lib/vmc/cli/space/base.rb +21 -0
  54. data/lib/vmc/cli/space/create.rb +56 -0
  55. data/lib/vmc/cli/space/delete.rb +95 -0
  56. data/lib/vmc/cli/space/rename.rb +39 -0
  57. data/lib/vmc/cli/space/space.rb +64 -0
  58. data/lib/vmc/cli/space/spaces.rb +55 -0
  59. data/lib/vmc/cli/space/take.rb +16 -0
  60. data/lib/vmc/cli/start/base.rb +80 -0
  61. data/lib/vmc/cli/start/colors.rb +13 -0
  62. data/lib/vmc/cli/start/info.rb +122 -0
  63. data/lib/vmc/cli/start/login.rb +92 -0
  64. data/lib/vmc/cli/start/logout.rb +13 -0
  65. data/lib/vmc/cli/start/target.rb +64 -0
  66. data/lib/vmc/cli/start/target_interactions.rb +37 -0
  67. data/lib/vmc/cli/start/targets.rb +16 -0
  68. data/lib/vmc/cli/user/base.rb +29 -0
  69. data/lib/vmc/cli/user/create.rb +39 -0
  70. data/lib/vmc/cli/user/delete.rb +25 -0
  71. data/lib/vmc/cli/user/passwd.rb +50 -0
  72. data/lib/vmc/cli/user/register.rb +42 -0
  73. data/lib/vmc/cli/user/users.rb +32 -0
  74. data/lib/vmc/constants.rb +13 -0
  75. data/lib/vmc/detect.rb +134 -0
  76. data/lib/vmc/errors.rb +17 -0
  77. data/lib/vmc/plugin.rb +56 -0
  78. data/lib/vmc/spacing.rb +89 -0
  79. data/lib/vmc/spec_helper.rb +1 -0
  80. data/lib/vmc/test_support.rb +4 -0
  81. data/lib/vmc/test_support/command_helper.rb +32 -0
  82. data/lib/vmc/test_support/common_input_examples.rb +14 -0
  83. data/lib/vmc/test_support/fake_home_dir.rb +16 -0
  84. data/lib/vmc/test_support/interact_helper.rb +29 -0
  85. data/lib/vmc/version.rb +3 -0
  86. data/spec/assets/hello-sinatra/Gemfile +3 -0
  87. data/spec/assets/hello-sinatra/main.rb +6 -0
  88. data/spec/features/new_user_flow_spec.rb +71 -0
  89. data/spec/spec_helper.rb +63 -0
  90. data/spec/vmc/cli/app/base_spec.rb +17 -0
  91. data/spec/vmc/cli/app/delete_spec.rb +188 -0
  92. data/spec/vmc/cli/app/instances_spec.rb +65 -0
  93. data/spec/vmc/cli/app/push/create_spec.rb +571 -0
  94. data/spec/vmc/cli/app/push_spec.rb +369 -0
  95. data/spec/vmc/cli/app/rename_spec.rb +104 -0
  96. data/spec/vmc/cli/app/scale_spec.rb +81 -0
  97. data/spec/vmc/cli/app/stats_spec.rb +62 -0
  98. data/spec/vmc/cli/domain/map_spec.rb +140 -0
  99. data/spec/vmc/cli/domain/unmap_spec.rb +73 -0
  100. data/spec/vmc/cli/organization/orgs_spec.rb +108 -0
  101. data/spec/vmc/cli/organization/rename_spec.rb +113 -0
  102. data/spec/vmc/cli/route/map_spec.rb +138 -0
  103. data/spec/vmc/cli/route/unmap_spec.rb +215 -0
  104. data/spec/vmc/cli/service/bind_spec.rb +25 -0
  105. data/spec/vmc/cli/service/delete_spec.rb +22 -0
  106. data/spec/vmc/cli/service/rename_spec.rb +105 -0
  107. data/spec/vmc/cli/service/service_spec.rb +23 -0
  108. data/spec/vmc/cli/service/unbind_spec.rb +25 -0
  109. data/spec/vmc/cli/space/rename_spec.rb +102 -0
  110. data/spec/vmc/cli/space/spaces_spec.rb +104 -0
  111. data/spec/vmc/cli/start/info_spec.rb +153 -0
  112. data/spec/vmc/cli/start/login_spec.rb +71 -0
  113. data/spec/vmc/cli/user/create_spec.rb +54 -0
  114. data/spec/vmc/cli/user/passwd_spec.rb +102 -0
  115. data/spec/vmc/cli/user/register_spec.rb +148 -0
  116. data/spec/vmc/cli_spec.rb +448 -0
  117. data/spec/vmc/detect_spec.rb +54 -0
  118. metadata +231 -124
  119. data/README.md +0 -155
  120. data/caldecott_helper/Gemfile +0 -10
  121. data/caldecott_helper/Gemfile.lock +0 -48
  122. data/caldecott_helper/server.rb +0 -43
  123. data/config/clients.yml +0 -17
  124. data/config/micro/offline.conf +0 -2
  125. data/config/micro/paths.yml +0 -22
  126. data/config/micro/refresh_ip.rb +0 -20
  127. data/lib/cli.rb +0 -48
  128. data/lib/cli/commands/admin.rb +0 -81
  129. data/lib/cli/commands/apps.rb +0 -1358
  130. data/lib/cli/commands/base.rb +0 -233
  131. data/lib/cli/commands/manifest.rb +0 -56
  132. data/lib/cli/commands/micro.rb +0 -115
  133. data/lib/cli/commands/misc.rb +0 -147
  134. data/lib/cli/commands/services.rb +0 -217
  135. data/lib/cli/commands/user.rb +0 -70
  136. data/lib/cli/config.rb +0 -176
  137. data/lib/cli/console_helper.rb +0 -163
  138. data/lib/cli/core_ext.rb +0 -122
  139. data/lib/cli/errors.rb +0 -19
  140. data/lib/cli/file_helper.rb +0 -123
  141. data/lib/cli/frameworks.rb +0 -265
  142. data/lib/cli/manifest_helper.rb +0 -316
  143. data/lib/cli/runner.rb +0 -633
  144. data/lib/cli/services_helper.rb +0 -104
  145. data/lib/cli/tunnel_helper.rb +0 -336
  146. data/lib/cli/usage.rb +0 -129
  147. data/lib/cli/version.rb +0 -7
  148. data/lib/cli/zip_util.rb +0 -102
  149. data/lib/vmc/client.rb +0 -574
  150. data/lib/vmc/const.rb +0 -27
  151. data/lib/vmc/micro.rb +0 -56
  152. data/lib/vmc/micro/switcher/base.rb +0 -97
  153. data/lib/vmc/micro/switcher/darwin.rb +0 -19
  154. data/lib/vmc/micro/switcher/dummy.rb +0 -15
  155. data/lib/vmc/micro/switcher/linux.rb +0 -16
  156. data/lib/vmc/micro/switcher/windows.rb +0 -31
  157. data/lib/vmc/micro/vmrun.rb +0 -158
@@ -1,233 +0,0 @@
1
- require 'rubygems'
2
- require 'interact'
3
- require 'terminal-table/import'
4
-
5
- module VMC::Cli
6
-
7
- module Command
8
-
9
- class Base
10
- include Interactive
11
-
12
- attr_reader :no_prompt, :prompt_ok
13
-
14
- MANIFEST = "manifest.yml"
15
-
16
- def initialize(options={})
17
- @options = options.dup
18
- @no_prompt = @options[:noprompts]
19
- @prompt_ok = !no_prompt
20
-
21
- # Suppress colorize on Windows systems for now.
22
- if WINDOWS
23
- VMC::Cli::Config.colorize = false
24
- end
25
-
26
- @path = @options[:path] || '.'
27
-
28
- load_manifest manifest_file if manifest_file
29
- end
30
-
31
- def manifest_file
32
- return @options[:manifest] if @options[:manifest]
33
- return @manifest_file if @manifest_file
34
-
35
- where = File.expand_path(@path)
36
- while true
37
- if File.exists?(File.join(where, MANIFEST))
38
- @manifest_file = File.join(where, MANIFEST)
39
- break
40
- elsif File.basename(where) == "/"
41
- @manifest_file = nil
42
- break
43
- else
44
- where = File.expand_path("../", where)
45
- end
46
- end
47
-
48
- @manifest_file
49
- end
50
-
51
- def load_manifest_structure(file)
52
- manifest = YAML.load_file file
53
-
54
- Array(manifest["inherit"]).each do |p|
55
- manifest = merge_parent(manifest, p)
56
- end
57
-
58
- if apps = manifest["applications"]
59
- apps.each do |k, v|
60
- client.infra = v['infra'] if v['infra']
61
- abs = File.expand_path(k, file)
62
- if Dir.pwd.start_with? abs
63
- manifest = merge_manifest(manifest, v)
64
- end
65
- end
66
- end
67
-
68
- manifest
69
- end
70
-
71
- def resolve_manifest(manifest)
72
- if apps = manifest["applications"]
73
- apps.each_value do |v|
74
- resolve_lexically(v, [manifest])
75
- end
76
- end
77
-
78
- resolve_lexically(manifest, [manifest])
79
- end
80
-
81
- def load_manifest(file)
82
- @manifest = load_manifest_structure(file)
83
- resolve_manifest(@manifest)
84
- end
85
-
86
- def merge_parent(child, path)
87
- file = File.expand_path("../" + path, manifest_file)
88
- merge_manifest(child, load_manifest_structure(file))
89
- end
90
-
91
- def merge_manifest(child, parent)
92
- merge = proc do |_, old, new|
93
- if new.is_a?(Hash) and old.is_a?(Hash)
94
- old.merge(new, &merge)
95
- else
96
- new
97
- end
98
- end
99
-
100
- parent.merge(child, &merge)
101
- end
102
-
103
- def resolve_lexically(val, ctx = [@manifest])
104
- case val
105
- when Hash
106
- val.each_value do |v|
107
- resolve_lexically(v, [val] + ctx)
108
- end
109
- when Array
110
- val.each do |v|
111
- resolve_lexically(v, ctx)
112
- end
113
- when String
114
- val.gsub!(/\$\{([[:alnum:]\-]+)\}/) do
115
- resolve_symbol($1, ctx)
116
- end
117
- end
118
-
119
- nil
120
- end
121
-
122
- def resolve_symbol(sym, ctx)
123
- case sym
124
- when "target-base"
125
- target_base(ctx)
126
-
127
- when "target-url"
128
- target_url(ctx)
129
-
130
- when "random-word"
131
- "%04x" % [rand(0x0100000)]
132
-
133
- else
134
- found = find_symbol(sym, ctx)
135
-
136
- if found
137
- resolve_lexically(found, ctx)
138
- found
139
- else
140
- err(sym, "Unknown symbol in manifest: ")
141
- end
142
- end
143
- end
144
-
145
- def find_symbol(sym, ctx)
146
- ctx.each do |h|
147
- if val = resolve_in(h, sym)
148
- return val
149
- end
150
- end
151
-
152
- nil
153
- end
154
-
155
- def resolve_in(hash, *where)
156
- find_in_hash(hash, ["properties"] + where) ||
157
- find_in_hash(hash, ["applications", @application] + where) ||
158
- find_in_hash(hash, where)
159
- end
160
-
161
- def manifest(*where)
162
- resolve_in(@manifest, *where)
163
- end
164
-
165
- def find_in_hash(hash, where)
166
- what = hash
167
- where.each do |x|
168
- return nil unless what.is_a?(Hash)
169
- what = what[x]
170
- end
171
-
172
- what
173
- end
174
-
175
- def target_url(ctx = [])
176
- find_symbol("target", ctx) ||
177
- (@client && @client.target) ||
178
- VMC::Cli::Config.target_url
179
- end
180
-
181
- def target_base(ctx = [])
182
- VMC::Cli::Config.base_of(find_symbol("target", ctx) || "api.#{client.suggest_url}")
183
- end
184
-
185
- # Inject a client to help in testing.
186
- def client(cli=nil)
187
- @client ||= cli
188
- return @client if @client
189
- @client = VMC::Client.new(target_url, auth_token)
190
- @client.trace = VMC::Cli::Config.trace if VMC::Cli::Config.trace
191
- @client.proxy_for @options[:proxy] if @options[:proxy]
192
- @client
193
- end
194
-
195
- def client_info
196
- @client_info ||= client.info
197
- end
198
-
199
- def auth_token
200
- @auth_token = VMC::Cli::Config.auth_token(@options[:token_file])
201
- end
202
-
203
- def runtimes_info
204
- return @runtimes if @runtimes
205
- info = client_info
206
- @runtimes = {}
207
- if info[:frameworks]
208
- info[:frameworks].each_value do |f|
209
- next unless f[:runtimes]
210
- f[:runtimes].each { |r| @runtimes[r[:name]] = r}
211
- end
212
- end
213
- @runtimes
214
- end
215
-
216
- def frameworks_info
217
- return @frameworks if @frameworks
218
- info = client_info
219
- @frameworks = []
220
- if info[:frameworks]
221
- info[:frameworks].each_value { |f| @frameworks << [f[:name]] }
222
- end
223
- @frameworks
224
- end
225
-
226
- def default_infra
227
- "aws"
228
- end
229
-
230
- end
231
- end
232
- end
233
-
@@ -1,56 +0,0 @@
1
- module VMC::Cli::Command
2
- class Manifest < Base
3
- include VMC::Cli::ManifestHelper
4
-
5
- def initialize(options)
6
- super
7
-
8
- # don't resolve any of the manifest template stuff
9
- if manifest_file
10
- @manifest = load_manifest_structure manifest_file
11
- else
12
- @manifest = {}
13
- end
14
- end
15
-
16
- def edit
17
- build_manifest
18
- save_manifest
19
- end
20
-
21
- def extend(which)
22
- parent = load_manifest_structure which
23
- @manifest = load_manifest_structure which
24
-
25
- build_manifest
26
-
27
- simplify(@manifest, parent)
28
-
29
- @manifest["inherit"] ||= []
30
- @manifest["inherit"] << which
31
-
32
- save_manifest(ask("Save where?"))
33
- end
34
-
35
- private
36
-
37
- def simplify(child, parent)
38
- return unless child.is_a?(Hash) and parent.is_a?(Hash)
39
-
40
- child.reject! do |k, v|
41
- if v == parent[k]
42
- puts "rejecting #{k}"
43
- true
44
- else
45
- simplify(v, parent[k])
46
- false
47
- end
48
- end
49
- end
50
-
51
- def build_manifest
52
- @application = ask("Configure for which application?", :default => ".")
53
- interact true
54
- end
55
- end
56
- end
@@ -1,115 +0,0 @@
1
- module VMC::Cli::Command
2
- class Micro < Base
3
-
4
- def initialize(args)
5
- super(args)
6
- end
7
-
8
- def offline(mode)
9
- command('offline')
10
- end
11
-
12
- def online(mode)
13
- command('online')
14
- end
15
-
16
- def status(mode)
17
- command('status')
18
- end
19
-
20
- def command(cmd)
21
- config = build_config
22
- switcher(config).send(cmd)
23
- store_config(config)
24
- end
25
-
26
- def switcher(config)
27
- case Micro.platform
28
- when :darwin
29
- switcher = VMC::Micro::Switcher::Darwin.new(config)
30
- when :linux
31
- switcher = VMC::Micro::Switcher::Linux.new(config)
32
- when :windows
33
- switcher = VMC::Micro::Switcher::Windows.new(config)
34
- when :dummy # for testing only
35
- switcher = VMC::Micro::Switcher::Dummy.new(config)
36
- else
37
- err "unsupported platform: #{Micro.platform}"
38
- end
39
- end
40
-
41
- # Returns the configuration needed to run the micro related subcommands.
42
- # First loads saved config from file (if there is any), then overrides
43
- # loaded values with command line arguments, and finally tries to guess
44
- # in case neither was used:
45
- # vmx location of micro.vmx file
46
- # vmrun location of vmrun command
47
- # password password for vcap user (in the guest vm)
48
- # platform current platform
49
- def build_config
50
- conf = VMC::Cli::Config.micro # returns {} if there isn't a saved config
51
-
52
- override(conf, 'vmx', true) do
53
- locate_vmx(Micro.platform)
54
- end
55
-
56
- override(conf, 'vmrun', true) do
57
- VMC::Micro::VMrun.locate(Micro.platform)
58
- end
59
-
60
- override(conf, 'password') do
61
- @password = ask("Please enter your Micro Cloud Foundry VM password (vcap user) password", :echo => "*")
62
- end
63
-
64
- conf['platform'] = Micro.platform
65
-
66
- conf
67
- end
68
-
69
- # Save the cleartext password if --save is supplied.
70
- # Note: it is due to vix we have to use a cleartext password :(
71
- # Only if --password is used and not --save is the password deleted from the
72
- # config file before it is stored to disk.
73
- def store_config(config)
74
- if @options[:save]
75
- warn("cleartext password saved in: #{VMC::Cli::Config::MICRO_FILE}")
76
- elsif @options[:password] || @password
77
- config.delete('password')
78
- end
79
-
80
- VMC::Cli::Config.store_micro(config)
81
- end
82
-
83
- # override with command line arguments and yield the block in case the option isn't set
84
- def override(config, option, escape=false, &blk)
85
- # override if given on the command line
86
- if opt = @options[option.to_sym]
87
- opt = VMC::Micro.escape_path(opt) if escape
88
- config[option] = opt
89
- end
90
- config[option] = yield unless config[option]
91
- end
92
-
93
- def locate_vmx(platform)
94
- paths = YAML.load_file(VMC::Micro.config_file('paths.yml'))
95
- vmx_paths = paths[platform.to_s]['vmx']
96
- vmx = VMC::Micro.locate_file('micro.vmx', 'micro', vmx_paths)
97
- err "Unable to locate micro.vmx, please supply --vmx option" unless vmx
98
- vmx
99
- end
100
-
101
- def self.platform
102
- case RUBY_PLATFORM
103
- when /darwin/ # x86_64-darwin11.2.0
104
- :darwin
105
- when /linux/ # x86_64-linux
106
- :linux
107
- when /mingw|mswin32|cygwin/ # i386-mingw32
108
- :windows
109
- else
110
- RUBY_PLATFORM
111
- end
112
- end
113
-
114
- end
115
- end
@@ -1,147 +0,0 @@
1
- module VMC::Cli::Command
2
-
3
- class Misc < Base
4
- def version
5
- say "af #{VMC::Cli::VERSION}"
6
- end
7
-
8
- def target
9
- return display JSON.pretty_generate({:target => target_url}) if @options[:json]
10
- banner "[#{target_url}]"
11
- end
12
-
13
- def targets
14
- targets = VMC::Cli::Config.targets
15
- return display JSON.pretty_generate(targets) if @options[:json]
16
- return display 'None specified' if targets.empty?
17
- targets_table = table do |t|
18
- t.headings = 'Target', 'Authorization'
19
- targets.each { |target, token| t << [target, token] }
20
- end
21
- display "\n"
22
- display targets_table
23
- end
24
-
25
- alias :tokens :targets
26
-
27
- def set_target(target_url)
28
- target_url = "https://#{target_url}" unless /^https?/ =~ target_url
29
- target_url = target_url.gsub(/\/+$/, '')
30
- client = VMC::Client.new(target_url)
31
- unless client.target_valid?
32
- if prompt_ok
33
- display "Host is not available or is not valid: '#{target_url}'".red
34
- show_response = ask "Would you like see the response?",
35
- :default => false
36
- display "\n<<<\n#{client.raw_info}\n>>>\n" if show_response
37
- end
38
- exit(false)
39
- else
40
- VMC::Cli::Config.store_target(target_url)
41
- say "Successfully targeted to [#{target_url}]".green
42
- end
43
- end
44
-
45
- def info
46
- info = client_info
47
- return display JSON.pretty_generate(info) if @options[:json]
48
-
49
- display "\n#{info[:description]}"
50
- display "For support visit #{info[:support]}"
51
- display ""
52
- display "Target: #{target_url} (v#{info[:version]})"
53
- display "Client: v#{VMC::Cli::VERSION}"
54
- if info[:user]
55
- display ''
56
- display "User: #{info[:user]}"
57
- end
58
- if usage = info[:usage] and limits = info[:limits]
59
- tmem = pretty_size(limits[:memory]*1024*1024)
60
- mem = pretty_size((usage[:memory] || 0)*1024*1024)
61
- tser = limits[:services]
62
- ser = usage[:services]
63
- tapps = limits[:apps] || 0
64
- apps = usage[:apps] || 0
65
- display "Usage: Memory (#{mem} of #{tmem} total)"
66
- display " Services (#{ser} of #{tser} total)"
67
- display " Apps (#{apps} of #{tapps} total)" if limits[:apps]
68
- end
69
- end
70
-
71
- def runtimes
72
- raise VMC::Client::AuthError unless client.logged_in?
73
- return display JSON.pretty_generate(runtimes_info) if @options[:json]
74
- return display "No Runtimes" if runtimes_info.empty?
75
- rtable = table do |t|
76
- t.headings = 'Name', 'Description', 'Version'
77
- runtimes_info.each_value { |rt| t << [rt[:name], rt[:description], rt[:version]] }
78
- end
79
- display "\n"
80
- display rtable
81
- end
82
-
83
- def infras
84
- infras_info = client.infras
85
- return display "Multiple infras not supported" if infras_info.empty?
86
- if infras_info.detect {|i| i.has_key?(:available) && i[:available] == false } # If one or more infras is unavailable
87
- itable = table do |t|
88
- t.headings = [ 'Name','Description','Message' ]
89
- infras_info.each { |i| t << [i[:infra], i[:description], i[:available] ? '' : 'Unavailable - ' + i[:unavail_message]] }
90
- end
91
- else # All infras are available
92
- itable = table do |t|
93
- t.headings = [ 'Name','Description' ]
94
- infras_info.each { |i| t << [i[:infra], i[:description]] }
95
- end
96
- end
97
- display "\n"
98
- display itable
99
- end
100
-
101
- def frameworks
102
- raise VMC::Client::AuthError unless client.logged_in?
103
- return display JSON.pretty_generate(frameworks_info) if @options[:json]
104
- return display "No Frameworks" if frameworks_info.empty?
105
- rtable = table do |t|
106
- t.headings = ['Name']
107
- frameworks_info.each { |f| t << f }
108
- end
109
- display "\n"
110
- display rtable
111
- end
112
-
113
- def aliases
114
- aliases = VMC::Cli::Config.aliases
115
- return display JSON.pretty_generate(aliases) if @options[:json]
116
- return display "No Aliases" if aliases.empty?
117
- atable = table do |t|
118
- t.headings = 'Alias', 'Command'
119
- aliases.each { |k,v| t << [k, v] }
120
- end
121
- display "\n"
122
- display atable
123
- end
124
-
125
- def alias(k, v=nil)
126
- k,v = k.split('=') unless v
127
- aliases = VMC::Cli::Config.aliases
128
- aliases[k] = v
129
- VMC::Cli::Config.store_aliases(aliases)
130
- display "Successfully aliased '#{k}' to '#{v}'".green
131
- end
132
-
133
- def unalias(key)
134
- aliases = VMC::Cli::Config.aliases
135
- if aliases.has_key?(key)
136
- aliases.delete(key)
137
- VMC::Cli::Config.store_aliases(aliases)
138
- display "Successfully unaliased '#{key}'".green
139
- else
140
- display "Unknown alias '#{key}'".red
141
- end
142
- end
143
-
144
- end
145
-
146
- end
147
-