Class: Morpheus::Cli::Logout
- Inherits:
-
Object
- Object
- Morpheus::Cli::Logout
show all
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/logout.rb
Instance Attribute Summary
Attributes included from CliCommand
#no_prompt
Instance Method Summary
collapse
Methods included from CliCommand
#build_common_options, #build_option_type_options, #command_name, #default_subcommand, #establish_remote_appliance_connection, #handle_subcommand, included, #interactive?, #noninteractive, #print_usage, #subcommand_aliases, #subcommand_usage, #subcommands, #verify_access_token!
Constructor Details
#initialize ⇒ Logout
include Morpheus::Cli::WhoamiHelper include Morpheus::Cli::AccountsHelper
Instance Method Details
#connect(opts) ⇒ Object
18
19
20
21
|
# File 'lib/morpheus/cli/logout.rb', line 18
def connect(opts)
end
|
#handle(args) ⇒ Object
27
28
29
|
# File 'lib/morpheus/cli/logout.rb', line 27
def handle(args)
logout(args)
end
|
#logout(args) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/morpheus/cli/logout.rb', line 31
def logout(args)
options = {}
optparse = OptionParser.new do|opts|
opts.banner = usage
build_common_options(opts, options, [:remote]) end
optparse.parse!(args)
connect(options)
begin
if !@appliance_name
print yellow,"Please specify a Morpheus Appliance to logout of with -r or see the command `remote use`#{reset}\n"
return
end
creds = Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials()
if !creds
print yellow,"You are not currently logged in to #{display_appliance(@appliance_name, @appliance_url)}\n",reset
return 0
else
Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).logout()
print cyan,"Goodbye\n",reset
end
rescue RestClient::Exception => e
print_rest_exception(e, options)
return 1
end
end
|
#usage ⇒ Object
23
24
25
|
# File 'lib/morpheus/cli/logout.rb', line 23
def usage
"Usage: morpheus logout"
end
|