aboutsummaryrefslogtreecommitdiff
path: root/sbosnap
blob: 256235620cc6415dcbedb32b52f7637fa819d193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
#
# vim: set ts=4:noet
#
# sbosnap
# script to pull down / update a local copy of the
# slackbuilds.org tree.
#
# author: Jacob Pipkin <j@dawnrazor.net>
# date: Setting Orange, the 37th day of Discord in the YOLD 3178
# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>

use 5.16.0;
use strict;
use warnings FATAL => 'all';
use SBO::Lib;
use File::Basename;
use Getopt::Long;

my $sbo_home = $config{SBO_HOME};
my $self = basename ($0);

sub show_usage () {
	print <<EOF
Usage: $self [options|command]

Options:
  -h|--help:
    this screen.
  -v|--version:
    version information.

Commands:
  fetch: initialize a local copy of the slackbuilds.org tree.
  update: update an existing local copy of the slackbuilds.org tree.
          (generally, you may prefer "sbocheck" over "$self update")

EOF
}

show_usage and exit 1 unless exists $ARGV[0];

my ($help, $vers);

GetOptions ('help|h' => \$help, 'version|v' => \$vers);

show_usage and exit 0 if $help;
show_version and exit 0 if $vers;

# check for a command and, if found, execute it
my $command;
if ($ARGV[0] =~ /fetch|update/) {
	$command = $ARGV[0];
} else { 
	show_usage and exit 1;
}

given ($command) {
	when ('fetch') {fetch_tree}
	when ('update') {update_tree}
}

exit 0;