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_helper, #scim_get_object, #scim_get_user_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



179
180
181
182
183
184
# File 'lib/uaa/cli/common.rb', line 179

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



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/uaa/cli/common.rb', line 224

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)


167
168
169
170
171
172
173
174
175
176
177
# File 'lib/uaa/cli/common.rb', line 167

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