use lib $RealDir;
use make::common;
+use make::console;
my %installed;
# $installed{name} = $version
}
my $mod;
- for (split /\n+/, $response->decoded_content) {
+ for (split /\n+/, $response->content) {
s/^\s+//; # ignore whitespace at start
next if /^#/;
if (/^module (\S+) (\S+) (\S+)/) {
$mod->{description} = $1;
} elsif (/^mask (.*)/) {
$mod->{mask} = $1;
- } elsif (m#^source (http://\S+)#) {
+ } elsif (/^source (\S+)/) {
parse_url $1;
} else {
print "Unknown line in $src: $_\n";
}
}
-my $action = $#ARGV >= 0 ? lc shift @ARGV : 'help';
-
-if ($action eq 'install') {
- for my $mod (@ARGV) {
+command 'install', 'Install a third-party module', sub {
+ for my $mod (@_) {
my $vers = $mod =~ s/=([-0-9.]+)// ? $1 : undef;
$mod = lc $mod;
unless ($modules{$mod}) {
}
$todo{$mod} = $ver;
}
-} elsif ($action eq 'upgrade') {
+};
+
+command 'upgrade', 'Upgrade a third-party module', sub {
my @installed = sort keys %installed;
for my $mod (@installed) {
next unless $mod =~ /^m_/;
%todo = %saved;
}
}
-} elsif ($action eq 'list') {
+};
+
+command 'list', 'List available third-party modules', sub {
my @all = sort keys %modules;
for my $mod (@all) {
my @vers = sort { ver_cmp() } keys %{$modules{$mod}};
my $vers = join ' ', map { $_ eq $instver ? "\e[1m$_\e[m" : $_ } @vers;
print "$mod ($vers) - $desc\n";
}
-} else {
- print <<ENDUSAGE
-Use: $0 <action> <args>
-Action is one of the following
- install install new modules
- upgrade upgrade installed modules
- list lists available modules
-
-For installing a package, specify its name or name=version to force the
-installation of a specific version.
-ENDUSAGE
-;exit 1;
-}
+ exit 0;
+};
+
+execute_command @ARGV;
resolve_deps(0);
$| = 1; # immediate print of lines without \n
-print "Processing changes for $action...\n";
+print "Processing changes...\n";
for my $mod (keys %installed) {
next if $todo{$mod};
print "Uninstalling $mod $installed{$mod}\n";
if ($response->is_success) {
open(MF, ">src/modules/$mod.cpp") or die "\nFilesystem not writable: $!";
- print MF $response->decoded_content;
+ print MF $response->content;
close(MF);
print " - done\n";
} else {