#!/usr/bin/ruby -wU
#
-# mailshears, to prune unused mail directories (and more).
+# mailshears, to prune your mail garden
#
# Load all of our lib/ code.
require 'mailshears'
# Define a usage string using the program name.
-exe = File.basename($PROGRAM_NAME)
-usage = "#{exe} [prune | rm <target> | mv <src> <dst>]"
+program_name = File.basename($PROGRAM_NAME)
# Defaults
mode_name = 'prune'
mode = :prune
+# Before doing anything else, check for "-h" and "--help" in the args,
+# because those should cause us to dump usage info and bail out.
+if ARGV.include?('-h') or ARGV.include?('--help') then
+ puts "Usage: #{UserInterface.usage(program_name)}"
+ Kernel.exit(ExitCodes::SUCCESS)
+end
+
+
# If a mode was supplied, it should be in ARGV[0].
if ARGV.length() > 0
mode_names = ['prune', 'rm', 'mv']
# here. Report it and exit with a failure code.
if not args_error_message.nil? then
STDERR.puts args_error_message
- puts "Usage: #{usage}"
+ puts "Usage: #{UserInterface.usage(program_name)}"
Kernel.exit(ExitCodes::BAD_COMMAND_LINE)
end
$stdout = STDOUT
if output_buffer.size > 0 then
- puts make_header(exe, plugin_module.to_s())
+ puts UserInterface.make_header(program_name, plugin_module.to_s())
puts output_buffer.string()
end
end