Class: VMC::User
- Inherits:
-
CLI
- Object
- Mothership
- CLI
- VMC::User
show all
- Defined in:
- lib/vmc/cli/user.rb
Instance Method Summary
collapse
Methods inherited from CLI
#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #default_action, #ensure_config_dir, #err, #execute, #fail, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?
Methods included from Spacing
#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes
#ask, #handler, #input_state, #list_choices, #prompt, #show_default
Instance Method Details
#create_user ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/vmc/cli/user.rb', line 30
def create_user
email = input[:email]
password = input[:password]
if !force? && password != input[:verify]
fail "Passwords don't match."
end
with_progress("Creating user") do
client.register(email, password)
end
end
|
#delete_user ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/vmc/cli/user.rb', line 53
def delete_user
email = input[:email]
return unless input[:really, email]
with_progress("Deleting #{c(email, :name)}") do
client.user(email).delete!
end
end
|
#passwd ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/vmc/cli/user.rb', line 84
def passwd
user = input[:user]
password = input[:password] if v2?
new_password = input[:new_password]
verify = input[:verify]
if new_password != verify
fail "Passwords don't match."
end
with_progress("Changing password") do
if v2?
user.change_password!(new_password, password)
else
user.password = new_password
user.update!
end
end
end
|
#users ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/vmc/cli/user.rb', line 7
def users
users =
with_progress("Getting users") do
client.users(:depth => 0)
end
spaced(users) do |u|
display_user(u)
end
end
|