Commit Diff
Diff:
1c272cf1799fcb19abd2f2d9d379e22f049654c6
6544c970896f6db39f7490bed9e65d8b48de9624
Commit:
6544c970896f6db39f7490bed9e65d8b48de9624
Tree:
24d6ae67c2d8f15adbf2c27745ed335688ef5dd7
Author:
fredgnix <fredgnix@a8afeb8c-277c-4b4a-a4f6-ef4c85adc32b>
Committer:
fredgnix <fredgnix@a8afeb8c-277c-4b4a-a4f6-ef4c85adc32b>
Date:
Sun Jan 1 16:44:05 2012 UTC
Message:
main CLI prog
blob - /dev/null
blob + 1bf2469b12c00d7431d5ff55f1c4b804e65b6f86 (mode 644)
--- /dev/null
+++ pkgtxt2db
@@ -0,0 +1,73 @@
+#!/usr/bin/env perl
+#
+# pkgtxt2db.pl
+#
+# copyright 2012 Frédéric Galusik <fredg~at~salixos~dot~org>
+#
+# License: BSD Revised
+#
+# Convert the Slackware/Salix PACKAGES.TXT file some various database
+# formats : CSV, json,
+#
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+use Pkgtxt2db;
+
+my $VERSION = 0.0;
+
+my $Pkgtxt2db = Pkgtxt2db->new();
+
+#
+# help - usage
+#
+sub usage {
+ print "Usage: $0 [options]\n\n";
+ print "Options:\n";
+ print " -c | --csv\t\tconvert to a CSV database\n";
+ print " -j | --json\t\tconvert to a JSON database\n";
+ print " -h | --help\t\tprint this message\n";
+ print " -v | --version\t\tprint pkgtxt2db version\n";
+ exit 0;
+}
+
+#
+# CLI options
+#
+my $version;
+my $help;
+my $scsv;
+my $sjson;
+
+GetOptions(
+ 'version' => \$version,
+ 'help' => \&usage,
+ 'csv' => \$scsv,
+ 'json' => \$sjson,
+ );
+if ($version) {
+ print "Pkgtxt2db, version $VERSION\n";
+ print "Copyright 2011-2012 Frédéric Galusik\n";
+ print "http://www.salixos.org/wiki/index.php/Pkgtxt2db\n";
+ exit 0;
+ }
+if ($scsv) {
+ Pkgtxt2db->get_file($Pkgtxt2db::url32,$Pkgtxt2db::pkgtxt);
+ Pkgtxt2db->salix_data();
+ Pkgtxt2db->mkdadb();
+ Pkgtxt2db->s2csv();
+ exit 0;
+ }
+if ($sjson) {
+ Pkgtxt2db->get_file($Pkgtxt2db::url32,$Pkgtxt2db::pkgtxt);
+ Pkgtxt2db->salix_data();
+ Pkgtxt2db->mkdadb();
+ Pkgtxt2db->s2json();
+ exit 0;
+ }
+else {
+ die "Wrong usage, run pkgtxt2db --help for information.\n";
+}
+
Frédéric Galusik