Class: VMC::Cli::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/commands/base.rb

Direct Known Subclasses

Admin, Apps, Misc, Services, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cli/commands/base.rb', line 13

def initialize(options={})
  @options = options.dup
  @no_prompt = @options[:noprompts]
  @prompt_ok = !no_prompt

  # Fix for system ruby and Highline (stdin) on MacOSX
  if RUBY_PLATFORM =~ /darwin/ && RUBY_VERSION == '1.8.7' && RUBY_PATCHLEVEL <= 174
    HighLine.track_eof = false
  end

  # Suppress colorize on Windows systems for now.
  if !!RUBY_PLATFORM['mingw'] || !!RUBY_PLATFORM['mswin32'] || !!RUBY_PLATFORM['cygwin']
    VMC::Cli::Config.colorize = false
  end

end

Instance Attribute Details

#no_promptObject (readonly)

Returns the value of attribute no_prompt.



11
12
13
# File 'lib/cli/commands/base.rb', line 11

def no_prompt
  @no_prompt
end

#prompt_okObject (readonly)

Returns the value of attribute prompt_ok.



11
12
13
# File 'lib/cli/commands/base.rb', line 11

def prompt_ok
  @prompt_ok
end

Instance Method Details

#auth_tokenObject



48
49
50
51
# File 'lib/cli/commands/base.rb', line 48

def auth_token
  return @auth_token if @auth_token
  @auth_token = VMC::Cli::Config.auth_token
end

#clientObject



30
31
32
33
34
35
36
# File 'lib/cli/commands/base.rb', line 30

def client
  return @client if @client
  @client = VMC::Client.new(target_url, auth_token)
  @client.trace = true if VMC::Cli::Config.trace
  @client.proxy_for @options[:proxy] if @options[:proxy]
  @client
end

#client_infoObject



38
39
40
41
# File 'lib/cli/commands/base.rb', line 38

def client_info
  return @client_info if @client_info
  @client_info = client.info
end

#target_urlObject



43
44
45
46
# File 'lib/cli/commands/base.rb', line 43

def target_url
  return @target_url if @target_url
  @target_url = VMC::Cli::Config.target_url
end