def logout(args)
options = {}
optparse = Morpheus::Cli::OptionParser.new do |opts|
opts.banner = usage
build_common_options(opts, options, [:remote, :quiet])
opts.footer = <<-EOT
Logout of a remote appliance.
This clears your credentials so that you will need to login again.
EOT
end
optparse.parse!(args)
verify_args!(args:args,count:0,optpare:optparse)
connect(options)
if !@appliance_name
print_error Morpheus::Terminal.angry_prompt
puts_error "Please specify a Morpheus Appliance to logout of with -r or see the command `remote use`"
return 1
end
wallet = Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials
token = wallet ? wallet['access_token'] : nil
if !token
if !options[:quiet]
puts "You are not currently logged in to #{display_appliance(@appliance_name, @appliance_url)}"
end
else
Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).logout()
if !options[:quiet]
puts "#{cyan}Logged out of #{@appliance_name}. Goodbye #{wallet['username']}!#{reset}"
end
end
Morpheus::Cli::Echo.recalculate_variable_map()
if Morpheus::Cli::Shell.has_instance?
Morpheus::Cli::Shell.instance.reinitialize()
end
return 0
end