Class: PI::Cli::Command::Base

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

Direct Known Subclasses

Apps, Dns, Misc, Projects, Services, User

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



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

def initialize(options={})
  @options = options.dup

  # 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']
    PI::Cli::Config.colorize = false
  end

end

Instance Method Details

#auth_tokenObject



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

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

#clientObject



27
28
29
30
31
32
33
# File 'lib/cli/commands/base.rb', line 27

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

#target_urlObject



35
36
37
# File 'lib/cli/commands/base.rb', line 35

def target_url
  @target_url = PI::Cli::Config.target_url
end