]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/rm_runner.rb
Fix broken nesting in lib/mv/plugins/postfixadmin.rb.
[mailshears.git] / lib / rm / rm_runner.rb
1 require 'common/errors'
2 require 'common/runner'
3
4 class RmRunner
5 include Runner
6
7 def run(plugin, *targets)
8 targets.each do |target|
9 remove_target(plugin, target)
10 end
11 end
12
13 private;
14
15 def remove_target(plugin, target)
16 # Wrap the "remove this thing" operation so that it can be reused
17 # in the prine plugin.
18 target_description = plugin.describe(target)
19
20 begin
21 plugin.delete(target)
22 msg = "Removed #{target.class.to_s().downcase()} #{target}"
23
24 # Only append the extra description if it's useful.
25 if not target_description.nil? and
26 not target_description.empty? and
27 not target_description == target.to_s() then
28 msg += " (#{target_description})"
29 end
30 msg += '.'
31
32 report(plugin, msg)
33 rescue NonexistentDomainError, NonexistentUserError => e
34 report(plugin, "#{target.class.to_s()} #{e.to_s} not found.")
35 end
36 end
37 end