Handle all passed options, chdir to bindir

Sat, 30 May 2015 02:58:07 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 30 May 2015 02:58:07 -0400
changeset 184
ddb5e993a367
parent 183
24804a083693
child 185
4e227517a5cd

Handle all passed options, chdir to bindir

.homedir-setup.rb file | annotate | diff | comparison | revisions
--- a/.homedir-setup.rb
+++ b/.homedir-setup.rb
@@ -21,19 +21,25 @@ def main
     [ '--setup', '-s', GetoptLong::NO_ARGUMENT ],
   );
 
-  case opts.get.shift
-  when '--help'
-    puts <<-ENDHELP.sub(/^\s+/,'')
-      #{$0} usage:
-       -h --help    This help message
-       -s --setup   Perform home directory setup (git clone)
-       -u --update  Update git stuff (git pull)
-    ENDHELP
-    exit 1
-  when '--setup'
-    setup
-  when '--update'
-    update
+  Dir.chdir(
+    File.dirname File.expand_path $0
+  )
+
+  opts.each do |opt, arg|
+    case opt
+    when '--help'
+      puts <<-ENDHELP.sub(/^\s+/,'')
+        #{$0} usage:
+         -h --help    This help message
+         -s --setup   Perform home directory setup (git clone)
+         -u --update  Update git stuff (git pull)
+      ENDHELP
+      exit 1
+    when '--setup'
+      setup
+    when '--update'
+      update
+    end
   end
 end
 

mercurial