Skip to content

Instantly share code, notes, and snippets.

@shimeji87
Last active April 9, 2023 08:21
Show Gist options
  • Save shimeji87/d641d05009480c901bb82411e65765fe to your computer and use it in GitHub Desktop.
Save shimeji87/d641d05009480c901bb82411e65765fe to your computer and use it in GitHub Desktop.
Haxelib Bulk Install
#! /usr/bin/perl
# Haxelib Bulk Install
# Install from git - [name] [github repo]
# Update library - [name] update
# Set library version - [name] set [version]
# Remove library - [name] remove/delete/del
use LWP::Simple;
use strict;
use warnings;
if ($ARGV[0]) {
open FILE, $ARGV[0];
my @libs = <FILE>;
my $len = @libs;
my $count = 1;
for (@libs) {
chomp;
my @spl = split(' ', $_);
if (lc($spl[1]) eq 'del' or lc($spl[1]) eq 'delete' or lc($spl[1]) eq 'remove') {
print "Removing " . $spl[0] . " [$count/$len]\n";
system("haxelib", "remove", $spl[0]);
$count++;
next;
} elsif (lc($spl[1]) eq 'update') {
print "Updating " . $spl[0] . " [$count/$len]\n";
system("haxelib", "update", $spl[0]);
$count++;
next;
} elsif (lc($spl[1]) eq 'set' and $spl[2]) {
print "Setting " . $spl[0] . " to " . $spl[2] . " [$count/$len]\n";
system("haxelib", "set", $spl[0], $spl[2]);
$count++;
next;
}
if (!head("https://lib.haxe.org/p/$_/")) {
if (head($spl[1])) {
print "Installing " . $spl[0] . " via git [$count/$len]\n";
system("haxelib", "git", $spl[0], $spl[1]);
$count++;
next;
}
print "$_ library not found [$count/$len]\n";
$count++;
next;
}
print "Installing $_ [$count/$len]\n";
system("haxelib", "install", $_);
$count++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment