Class: CF::UAA::MiscCli

Inherits:
CommonCli show all
Defined in:
lib/uaa/cli/common.rb

Instance Method Summary collapse

Methods inherited from CommonCli

#askd, #auth_header, #clientid, #clientname, #clientsecret, #complain, #debug?, #handle_request, #passcode, #scim_common_list, #scim_get_object, #scim_request, #trace?, #update_target_info, #username, #userpwd, #verified_pwd

Methods inherited from Topic

#add_command, #ask, #ask_pwd, commands, define_option, desc, #gripe, #help_col_start, #initialize, #opt_help, #opt_strs, option_defs, #opts, #pp, #print_tree, #say, #say_cmd_helper, #say_command_help, #say_commands, #say_definition, #say_help, #terminal_columns, topic

Constructor Details

This class inherits a constructor from CF::UAA::Topic

Instance Method Details

#bad_uaa_url(url, info, skip_ssl_validation = false, ca_cert = nil) ⇒ Object



150
151
152
153
154
155
# File 'lib/uaa/cli/common.rb', line 150

def bad_uaa_url(url, info, skip_ssl_validation = false, ca_cert = nil)
  info.replace(@cli_class.uaa_info_client(url.to_s, skip_ssl_validation, ca_cert).server)
  nil
rescue Exception => e
  "failed to access #{url}: #{e.message}"
end

#config_pp(tgt = nil, ctx = nil) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/uaa/cli/common.rb', line 192

def config_pp(tgt = nil, ctx = nil)
  Config.config.each_with_index do |(k, v), i|
    next if tgt && tgt != k
    say ""
    splat = v[:current] ? '*' : ' '
    pp "[#{i}]#{splat}[#{k}]"
    v.each {|tk, tv| pp(tv, 2, terminal_columns, tk) unless [:contexts, :current, :prompts].include?(tk)}
    next unless v[:contexts]
    v[:contexts].each_with_index do |(sk, sv), si|
      next if ctx && ctx != sk
      say ""
      splat = sv[:current] && v[:current]? '*' : ' '
      sv.delete(:current)
      pp "[#{si}]#{splat}[#{sk}]", 2
      pp sv, 4, 0
    end
  end
  say ""
end

#normalize_url(url, scheme = nil) ⇒ Object

Raises:

  • (ArgumentError)


138
139
140
141
142
143
144
145
146
147
148
# File 'lib/uaa/cli/common.rb', line 138

def normalize_url(url, scheme = nil)
  url = url.strip.gsub(/\/*$/, "")
  raise ArgumentError, "invalid whitespace in target url" if url =~ /\s/
  unless url =~ /^https?:\/\//
    return unless scheme
    url = "#{scheme}://#{url}"
  end
  url = URI.parse(url)
  url.host.downcase!
  url.to_s.to_sym
end