blob: f065a4cbc016a0e37146f617f3d4dc0550392435 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
package SBO::App::Snap;
# vim: ts=2:et
#
# 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 Getopt::Long qw/ GetOptionsFromArray /;
use parent 'SBO::App';
sub _parse_opts {
my $class = shift;
my @ARGS = @_;
my ($help, $vers);
GetOptionsFromArray(
\@ARGS,
'help|h' => \$help,
'version|v' => \$vers,
);
return { help => $help, vers => $vers, args => \@ARGS, };
}
sub show_usage {
my $self = shift;
my $fname = $self->{fname};
print <<"EOF";
Usage: $fname [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 "$fname update")
EOF
return 1;
}
sub run {
my $self = shift;
my @args = @{ $self->{args} };
if ($self->{help}) { $self->show_usage(); return 0 }
if ($self->{vers}) { $self->show_version(); return 0 }
# check for a command and, if found, execute it
$args[0] //= '';
if ($args[0] eq 'fetch') {
fetch_tree()
} elsif ($args[0] eq 'update') {
update_tree()
} else {
$self->show_usage();
return 1;
}
return 0;
}
1;
|