- if leftover_domains.size > 0 or leftover_accounts.size > 0
- # The header that we output before the list of domains/accounts.
- # Just the path of this script, the current time, and the plugin name.
- header = "#{$0}, "
-
- current_time = Time.now()
- if current_time.respond_to?(:iso8601)
- # Somehow this method is missing on some machines.
- header += current_time.iso8601.to_s
- else
- # Fall back to whatever this looks like.
- header += current_time.to_s + "\n"
- end
-
- header += 'Plugin: ' + plugin_name + "\n"
- puts header
- puts '-' * header.size # Underline the header.
-
- leftover_domains.each do |domain|
- puts "Found: #{domain} (#{plugin.describe_domain(domain)})"
- end
-
- leftover_accounts.each do |account|
- puts "Found: #{account} (#{plugin.describe_account(account)})"
- end
-
- if Configuration::I_MEAN_BUSINESS
- leftover_domains.each do |domain|
- plugin.delete_domain(domain)
- puts "Removed: #{domain} (#{plugin.describe_domain(domain)})"
- end
-
- leftover_accounts.each do |account|
- plugin.delete_account(account)
- puts "Removed: #{account} (#{plugin.describe_account(account)})"
- end
- end
-
- puts ""
+ return header
+end
+
+
+plugin_class = nil
+runner_class = nil
+dummy_runner_class = nil
+
+if mode == :rm then
+ plugin_class = RmPlugin
+ runner_class = RmRunner
+ dummy_runner_class = RmDummyRunner
+elsif mode == :mv then
+ plugin_class = MvPlugin
+ runner_class = MvRunner
+ dummy_runner_class = MvDummyRunner
+else
+ # Safe, catch-all default
+ plugin_class = PrunePlugin
+ runner_class = PruneRunner
+ dummy_runner_class = PruneDummyRunner
+end
+
+
+# Buffer the output so that we can avoid printing the informational
+# header when no plugins produce output.
+require 'stringio'
+output_buffer = StringIO.new()
+$stdout = output_buffer
+
+plugin_class.includers.each do |plugin_class_includer|
+ plugin = plugin_class_includer.new(cfg)
+
+ if cfg.i_mean_business then
+ runner = runner_class.new()
+ else
+ runner = dummy_runner_class.new()