]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - bin/mailshears
mailshears.gemspec: bump version to 0.1.0
[mailshears.git] / bin / mailshears
index c5efabb32b5b1be125275c7f17279421d23b5f58..179311207cabfc99ec397fc784563d9f23dfc948 100755 (executable)
@@ -1,19 +1,26 @@
 #!/usr/bin/ruby -wU
 #
-# mailshears, to prune unused mail directories (and more).
+# mailshears, to mangle 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']
@@ -48,7 +55,7 @@ end
 # 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
 
@@ -115,7 +122,7 @@ ensure
   $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