]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - bin/mailshears
doc/COPYING: add one to state the "or later" bit
[mailshears.git] / bin / mailshears
index c5efabb32b5b1be125275c7f17279421d23b5f58..6161d572da3f6d69f218e6042f94af419597f109 100755 (executable)
@@ -1,19 +1,26 @@
 #!/usr/bin/ruby -wU
 #
 #!/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.
 #
 
 # 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
 
 
 # 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']
 # 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
 # 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
 
   Kernel.exit(ExitCodes::BAD_COMMAND_LINE)
 end
 
@@ -115,7 +122,7 @@ ensure
   $stdout = STDOUT
 
   if output_buffer.size > 0 then
   $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
     puts output_buffer.string()
   end
 end