Class: PostyClient::Command::UserCommand
- Inherits:
-
Thor
- Object
- Thor
- PostyClient::Command::UserCommand
show all
- Includes:
- FinderConcerns, Resources
- Defined in:
- lib/posty_client/command/user_command.rb
Instance Method Summary
collapse
#find_domain_alias_by_domain_and_name, #find_domain_by_name, #find_user_alias_by_email_and_name, #find_user_by_email, #user_and_domain_from_email
Instance Method Details
#add(name) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/posty_client/command/user_command.rb', line 17
def add(name)
user = find_user_by_email(name)
password = ask('Password?')
unless password.blank?
user.attributes['password'] = password
end
unless user.save
say("#{name} save failed: #{user.errors}", :red)
exit 1
end
end
|
#delete(name) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/posty_client/command/user_command.rb', line 47
def delete(name)
user = find_user_by_email(name)
if user.new_resource?
say("#{name} unknown", :red)
exit 1
end
unless user.delete
say("#{name} delete failed: #{user.errors}", :red)
exit 1
end
end
|
#list(domain) ⇒ Object
10
11
12
13
14
|
# File 'lib/posty_client/command/user_command.rb', line 10
def list(domain)
domain = Domain.new(domain)
users = domain.users
puts users.map(&:name)
end
|
#rename(name, new_name) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/posty_client/command/user_command.rb', line 32
def rename(name, new_name)
user = find_user_by_email(name)
if user.new_resource?
say("#{name} unknown", :red)
exit 1
end
user.attributes['name'] = new_name
unless user.save
say("#{name} save failed: #{user.errors}", :red)
exit 1
end
end
|