commit f898fd0609fa00e399f633ea391ac19549969ad5 Author: Maxwell Jeffress Date: Mon Aug 25 20:24:02 2025 +1000 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..36555a7 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# dig + +Dig is a simple package manager for Ground. At this point in time it is quite basic. + +## Installation + +You'll need to manually install Ground, and the "request", "file", and "exec" libraries yourself. This will be automated in future. + +Once that is done, you can install the dig package manager wherever you need it. + +## Usage + +`digpkg install pkgname`: Installs the package specified to /usr/lib/ground. Requires root permissions. + +`digpkg help`: Shows help. + +## Package list + +Go to https://ground.chookspace.com/pkgs to see the list. If you've made a Ground library and would like it packaged, please send me an email (max at chookspace dot com). + diff --git a/digpkg b/digpkg new file mode 100755 index 0000000..62ed3ab --- /dev/null +++ b/digpkg @@ -0,0 +1,79 @@ +#!/usr/bin/env ground + +# dig package manager +# this is a simple package manager for the Ground programming language + +extern "request" +extern "file" +extern "exec" + +set &rootURL "https://ground.chookspace.com/pkgs/" + +getlistsize *args &size +greater $size 0 &cond +if $cond %checkArgs + +stdlnout "Dig package manager" +stdlnout "Type 'dig install pkgname' to install a package or 'dig help' for more information" +end 1 + +@checkArgs + +getlistat *args 0 &instruction + +equal $instruction "install" &cond +if $cond %install + +equal $instruction "help" &cond +if $cond %help + +@install +greater $size 1 &cond +if $cond %installcontinue +stdlnout "Usage: dig install pkgname" +end 1 + +@installcontinue + +# Download the package +getlistat *args 1 &pkgname +stdout "Downloading " +stdlnout $pkgname + +add $pkgname ".tar" &pkgfile +add $rootURL $pkgfile &url +add "/tmp/" $pkgfile &tmpstorage + +pusharg $url +pusharg $tmpstorage +call !saveContents &status + +if $status %downloadSuccess +stdlnout "Download not successful" +end 1 + +@downloadSuccess + +# Extract using tar on the system +stdout "Extrating " +stdlnout $pkgname +add "tar -xf " $tmpstorage &cmd +add $cmd " -C /usr/lib/ground" &cmd + +pusharg $cmd +call !exec &status +equal 0 $status &cond + +if $cond %extractSuccess +stdlnout "Extraction not successful" +end 1 + +@extractSuccess + +# Report success to the user +stdlnout "Success!" +end 0 + +@help +stdlnout "" +end 0