Merge from default mhoward-lt

Thu, 16 Oct 2014 16:01:09 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 16 Oct 2014 16:01:09 -0400
branch
mhoward-lt
changeset 153
a006fee06b80
parent 151
a8216c3221af (current diff)
parent 152
69896d410e89 (diff)
child 161
f44901f85f39

Merge from default

--- a/.homedir-setup.rb
+++ b/.homedir-setup.rb
@@ -3,11 +3,35 @@
 
 # we don't yet have rbenv so keep safe for ruby 1.9
 
+require 'getoptlong'
+
 if `which git` == ''
   puts "please install git"
   exit 1 
 end
 
+def main
+  opts = GetoptLong.new(
+    [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
+    [ '--update', '-u', GetoptLong::NO_ARGUMENT ],
+    [ '--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
+  end
+end
 
 # just checks and bails after each call, output already in STDERR
 def do_cmds (*cmds)
@@ -18,51 +42,70 @@ def do_cmds (*cmds)
 end
 
 
+def setup
 
-# oh-my-zsh {{{
-  # some custom zsh files are already in .oh-my-zsh.cust
+  # oh-my-zsh {{{
+    # some custom zsh files are already in .oh-my-zsh.cust
+
+    if Dir.exists?('.oh-my-zsh/.git')
+      puts "oh-my-zsh already installed"
+    else
+      puts "Installing oh-my-zsh..."
+
+      do_cmds \
+        'git clone git://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh'
+
+    end
 
-  if Dir.exists?('.oh-my-zsh/.git')
-    puts "oh-my-zsh already installed"
-  else
-    puts "Installing oh-my-zsh..."
+  # }}}
+
+
+  # plenv {{{
 
-    do_cmds \
-      'git clone git://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh'
+    if Dir.exists?('.plenv')
+      puts "plenv already installed"
+    else
+      puts "Installing plenv..."
 
-  end
+      do_cmds \
+        'git clone git://github.com/tokuhirom/plenv.git .plenv',
+        'git clone git://github.com/tokuhirom/Perl-Build.git .plenv/plugins/perl-build/'
 
-# }}}
+    end
+
+  # }}}
 
 
-# plenv {{{
+  # rbenv {{{
+    if Dir.exists?('.rbenv')
+      puts "rbenv already installed"
+    else
+      puts "Installing rbenv..."
 
-  if Dir.exists?('.plenv')
-    puts "plenv already installed"
-  else
-    puts "Installing plenv..."
+      do_cmds \
+        'git clone https://github.com/sstephenson/rbenv.git .rbenv',
+        'git clone https://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build/'
+
+    end
+  # }}}
 
-    do_cmds \
-      'git clone git://github.com/tokuhirom/plenv.git .plenv',
-      'git clone git://github.com/tokuhirom/Perl-Build.git .plenv/plugins/perl-build/'
+end
+
+def update
 
+  [
+    '.oh-my-zsh',
+    '.plenv',
+    '.plenv/plugins/perl-build',
+    '.rbenv',
+    '.rbenv/plugins/ruby-build',
+  ].each do |dir|
+    do_cmds \
+      "chdir ~/#{dir} && git pull origin master"
   end
 
-# }}}
-
 
-# rbenv {{{
-  if Dir.exists?('.rbenv')
-    puts "rbenv already installed"
-  else
-    puts "Installing rbenv..."
+end
 
-    do_cmds \
-      'git clone https://github.com/sstephenson/rbenv.git .rbenv',
-      'git clone https://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build/'
+main
 
-  end
-# }}}
-
-
-

mercurial