]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
bin/mailshears: print usage info and exit on -h or --help
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 20 Apr 2024 23:29:47 +0000 (19:29 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 20 Apr 2024 23:37:21 +0000 (19:37 -0400)
bin/mailshears

index d9d16253cee734bba0428d64c0cbf07d036de669..179311207cabfc99ec397fc784563d9f23dfc948 100755 (executable)
@@ -13,6 +13,14 @@ program_name = File.basename($PROGRAM_NAME)
 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']