]> git.donarmstrong.com Git - bin.git/commitdiff
change sa to a perl script
authorDon Armstrong <don@donarmstrong.com>
Sun, 30 Oct 2005 05:19:24 +0000 (05:19 +0000)
committerDon Armstrong <don@donarmstrong.com>
Sun, 30 Oct 2005 05:19:24 +0000 (05:19 +0000)
sa

diff --git a/sa b/sa
index 1dba9221d4a27c5d6c0f53a0f092f62407899fcd..d652cccd3d6c39d473dd0b3fac3113f73c70fa93 100755 (executable)
--- a/sa
+++ b/sa
@@ -1,15 +1,82 @@
-#!/bin/sh
+#!/usr/bin/perl
 
-# sync all script
+use warnings;
+use strict;
 
-# attempt to sync all known svn projects
+use Getopt::Long;
+use Pod::Usage;
 
-if [ "$1" == "quick" ]; then
-    IGNORE="--ignore-externals";
-fi;
+=head1 NAME
 
-for dir in ~/ ~/.hide ~/projects/propel ~/bin ~/lib; do 
-    if [ -e $dir/.svn ]; then
-       svn update $IGNORE $dir;
-    fi;
-done;
\ No newline at end of file
+sa - sync all
+
+=head1 SYNOPSIS
+
+sa [options] [status|update|checkout] [directories to sync]
+
+ Options:
+  --quick, -Q don't update external projects
+  --quiet, -q be quiet
+  --debug, -d debugging level (Default 0)
+  --help, -h display this help
+  --man, -m display manual
+
+=head1 OPTIONS
+
+=over
+
+=item B<--debug, -d>
+
+Debug verbosity. (Default 0)
+
+=item B<--help, -h>
+
+Display brief useage information.
+
+=item B<--man, -m>
+
+Display this manual.
+
+=back
+
+=head1 EXAMPLES
+
+=cut
+
+
+
+use User;
+use vars qw($DEBUG);
+
+# XXX parse config file
+
+my %options = (quick           => 1,
+              quiet           => 0,
+              debug           => 0,
+              help            => 0,
+              man             => 0,
+             );
+
+GetOptions(\%options,'debug|d+','help|h|?','man|m');
+
+pod2usage() if $options{help};
+pod2usage({verbose=>2}) if $options{man};
+
+$DEBUG = $options{debug};
+
+my $command;
+
+if (@ARGV and $ARGV[0] =~ /^(st(?:atus)?|up(?:date)?|checkout)$/) {
+     $command = $ARGV[0];
+}
+else {
+     $command = 'status';
+}
+
+my $HOME=User->Home;
+
+for my $dir (map{"${HOME}/$_"} '',qw(.hide bin lib)) {
+     if (-e "$dir/.svn") {
+         system('svn',$command,$dir);
+     }
+}