Class: CF::UAA::Cli

Inherits:
BaseCli show all
Defined in:
lib/uaa/cli/runner.rb

Class Method Summary collapse

Methods inherited from BaseCli

run

Class Method Details

.configure(config_file = "", input = $stdin, output = $stdout, print_on_trace = false) ⇒ Object



29
30
31
32
33
34
# File 'lib/uaa/cli/runner.rb', line 29

def self.configure(config_file = "", input = $stdin, output = $stdout,
    print_on_trace = false)
  @config_file, @input, @output = config_file, input, output
  @print_on_trace = print_on_trace
  self
end

.handle_bad_command(args, msg) ⇒ Object



36
37
38
39
40
# File 'lib/uaa/cli/runner.rb', line 36

def self.handle_bad_command(args, msg)
  @output.puts "\n#{msg}"
  run args.unshift("help")
  nil
end

.preprocess_options(args, opts) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/uaa/cli/runner.rb', line 42

def self.preprocess_options(args, opts)
  return args.replace(["version"]) if opts[:version]
  return args.unshift("help") if args.empty? || opts[:help] && args[0] != "version"
  Config.load(opts[:config] || @config_file) if opts.key?(:config) || !Config.loaded?
  [:trace, :debug].each do |k|
    opts[k] = true if !opts.key?(k) && Config.target && Config.context && Config.value(k)
  end

  @uaa_logger = Util.default_logger(opts[:trace]? :trace: opts[:debug]? :debug: :warn, @output)
end

.uaa_info_client(url = Config.target, skip_ssl_validation = false, ca_cert = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/uaa/cli/runner.rb', line 53

def self.uaa_info_client(url = Config.target, skip_ssl_validation = false, ca_cert = nil)
  if Config.config[url]
    skip_ssl_validation = Config.config[url][:skip_ssl_validation]
    ca_cert = Config.config[url][:ca_cert]
  end
  client = Info.new(url, { skip_ssl_validation: skip_ssl_validation, ssl_ca_file: ca_cert })
  client.logger = @uaa_logger
  client
end