Method: VMC::Cli::Command::Misc#set_target

Defined in:
lib/cli/commands/misc.rb

#set_target(target_url) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cli/commands/misc.rb', line 27

def set_target(target_url)
  target_url = "https://#{target_url}" unless /^https?/ =~ target_url
  target_url = target_url.gsub(/\/+$/, '')
  client = VMC::Client.new(target_url)
  unless client.target_valid?
    if prompt_ok
      display "Host is not available or is not valid: '#{target_url}'".red
      show_response = ask "Would you like see the response?",
                          :default => false
      display "\n<<<\n#{client.raw_info}\n>>>\n" if show_response
    end
    exit(false)
  else
    VMC::Cli::Config.store_target(target_url)
    say "Successfully targeted to [#{target_url}]".green
  end
end