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, password = nil, quota = 0) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/posty_client/command/user_command.rb', line 17
def add(name, password=nil, quota=0)
user = find_user_by_email(name)
if quota.present?
user.quota = quota
end
if password.blank?
password = ask('Password?')
end
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
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/posty_client/command/user_command.rb', line 54
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
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/posty_client/command/user_command.rb', line 39
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
|