Class: VMC::Cli::Command::Base
- Inherits:
-
Object
- Object
- VMC::Cli::Command::Base
show all
- Includes:
- Interactive
- Defined in:
- lib/cli/commands/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Base
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/cli/commands/base.rb', line 15
def initialize(options={})
@options = options.dup
@no_prompt = @options[:noprompts]
@prompt_ok = !no_prompt
if WINDOWS
VMC::Cli::Config.colorize = false
end
end
|
Instance Attribute Details
#no_prompt ⇒ Object
Returns the value of attribute no_prompt.
13
14
15
|
# File 'lib/cli/commands/base.rb', line 13
def no_prompt
@no_prompt
end
|
#prompt_ok ⇒ Object
Returns the value of attribute prompt_ok.
13
14
15
|
# File 'lib/cli/commands/base.rb', line 13
def prompt_ok
@prompt_ok
end
|
Instance Method Details
#auth_token ⇒ Object
48
49
50
|
# File 'lib/cli/commands/base.rb', line 48
def auth_token
@auth_token ||= VMC::Cli::Config.auth_token
end
|
#client(cli = nil) ⇒ Object
Inject a client to help in testing.
27
28
29
30
31
32
33
34
|
# File 'lib/cli/commands/base.rb', line 27
def client(cli=nil)
@client ||= cli
return @client if @client
@client = VMC::Client.new(target_url, auth_token)
@client.trace = VMC::Cli::Config.trace if VMC::Cli::Config.trace
@client.proxy_for @options[:proxy] if @options[:proxy]
@client
end
|
#client_info ⇒ Object
36
37
38
|
# File 'lib/cli/commands/base.rb', line 36
def client_info
@client_info ||= client.info
end
|
#frameworks_info ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/cli/commands/base.rb', line 65
def frameworks_info
return @frameworks if @frameworks
info = client_info
@frameworks = []
if info[:frameworks]
info[:frameworks].each_value { |f| @frameworks << [f[:name]] }
end
@frameworks
end
|
#runtimes_info ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cli/commands/base.rb', line 52
def runtimes_info
return @runtimes if @runtimes
info = client_info
@runtimes = {}
if info[:frameworks]
info[:frameworks].each_value do |f|
next unless f[:runtimes]
f[:runtimes].each { |r| @runtimes[r[:name]] = r}
end
end
@runtimes
end
|
#target_base ⇒ Object
44
45
46
|
# File 'lib/cli/commands/base.rb', line 44
def target_base
@target_base ||= VMC::Cli::Config.suggest_url
end
|
#target_url ⇒ Object
40
41
42
|
# File 'lib/cli/commands/base.rb', line 40
def target_url
@target_url ||= VMC::Cli::Config.target_url
end
|