Class: CF::UAA::Cli

Inherits:
BaseCli show all
Defined in:
lib/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



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

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



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

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

.preprocess_options(args, opts) ⇒ Object



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

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) ⇒ Object



52
53
54
55
56
# File 'lib/cli/runner.rb', line 52

def self.uaa_info_client(url = Config.target)
  client = Info.new(url)
  client.logger = @uaa_logger
  client
end