aboutsummaryrefslogtreecommitdiff
path: root/sbosnap
blob: f2777b8ab56c93cdefa30bd9a08e61d8b6b53ccd (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
#!/usr/bin/perl
#
# vim: set ts=4:noet
#
# sbosnap
# script to pull down / update a local copy of the slackbuilds.org tree.
#
# authors: Jacob Pipkin <j@dawnrazor.net>
#          Luke Williams <xocel@iquidus.org>
#          Andreas Guldstrand <andreas.guldstrand@gmail.com>
# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>

use 5.16.0;
use strict;
use warnings FATAL => 'all';
use SBO::Lib qw/ fetch_tree update_tree %config show_version /;
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
	return 1;
}

my ($help, $vers);

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

if ($help) { show_usage(); exit 0 }
if ($vers) { show_version(); exit 0 }

# check for a command and, if found, execute it
$ARGV[0] //= '';

if ($ARGV[0] eq 'fetch') {
	fetch_tree()
} elsif ($ARGV[0] eq 'update') {
	update_tree()
} else {
	show_usage();
	exit 1;
}

exit 0;