]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/rm_runner.rb
1 require 'common/errors'
2 require 'common/runner'
7 def run(plugin
, *targets
)
8 targets
.each
do |target
|
9 # Why think too hard? An user has an @, a domain doesn't.
10 if target
.include?('@') then
12 user_description
= plugin
.describe_user(target
)
13 plugin
.delete_user(target
)
14 report(plugin
, "Removed user: #{target} (#{user_description})")
16 rescue NonexistentUserError
=> e
17 report(plugin
, "User not found: #{e.to_s}")
18 rescue StandardError
=> e
19 report(plugin
, "There was an error removing the user: #{e.to_s}")
20 Kernel
.exit(ExitCodes
::DATABASE_ERROR)
24 domain_description
= plugin
.describe_domain(target
)
25 plugin
.delete_domain(target
)
26 report(plugin
, "Removed domain: #{target} (#{domain_description})")
28 rescue NonexistentUserError
=> e
29 # Can happen in the usernames.each... block.
30 report(plugin
, "User not found: #{e.to_s}")
31 rescue NonexistentDomainError
=> e
32 report(plugin
, "Domain not found: #{e.to_s}")
33 rescue StandardError
=> e
34 report(plugin
, "There was an error removing the domain: #{e.to_s}")
35 Kernel
.exit(ExitCodes
::DATABASE_ERROR)