]> git.donarmstrong.com Git - bin.git/blob - sa
update sa
[bin.git] / sa
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Getopt::Long;
7 use Pod::Usage;
8
9 =head1 NAME
10
11 sa - sync all
12
13 =head1 SYNOPSIS
14
15 sa [options] [status|update|checkout] [directories to sync]
16
17  Options:
18   --quick, -Q don't update external projects
19   --quiet, -q be quiet
20   --debug, -d debugging level (Default 0)
21   --help, -h display this help
22   --man, -m display manual
23
24 =head1 OPTIONS
25
26 =over
27
28 =item B<--debug, -d>
29
30 Debug verbosity. (Default 0)
31
32 =item B<--help, -h>
33
34 Display brief useage information.
35
36 =item B<--man, -m>
37
38 Display this manual.
39
40 =back
41
42 =head1 EXAMPLES
43
44 =cut
45
46
47
48 use User;
49 use vars qw($DEBUG);
50
51 # XXX parse config file
52
53 my %options = (quick           => 0,
54                quiet           => 1,
55                debug           => 0,
56                help            => 0,
57                man             => 0,
58               );
59
60 GetOptions(\%options,'quick|Q!','quiet|q!','debug|d+','help|h|?','man|m');
61
62 pod2usage() if $options{help};
63 pod2usage({verbose=>2}) if $options{man};
64
65 $DEBUG = $options{debug};
66
67 my $command;
68
69 if (@ARGV and $ARGV[0] =~ /^(st(?:atus)?|up(?:date)?|checkout)$/) {
70      $command = $ARGV[0];
71 }
72 else {
73      $command = 'status';
74 }
75
76 my $HOME=User->Home;
77
78 for my $dir (map{"${HOME}/$_"} '',qw(.hide bin lib)) {
79      if (-e "$dir/.svn") {
80           system('svn',
81                  $command,
82                  $options{quiet}?'-q':(),
83                  $options{quick}?('--ignore-externals','-N'):(),
84                  $dir,
85                 );
86      }
87 }