simplification
Download
33 lines 1 KiBNomsuModified 2026-11-07executable raw
12345678910111213141516171819202122232425262728293031323334
#!/usr/bin/env nomsu -V8.0.0
###
    A tool to uninstall third party Nomsu packages (the inverse of the install tool)
    
    Usage:
        nomsu -t uninstall <package_names...>
    
use "filesystem"
use "commandline"
use "shell"

(run command $cmd) means:
    say $cmd
    try:
        sh> $cmd
    ..if it fails:
        say ("
            Sorry, the uninstall failed. You may need to re-run as root with `sudo` in front of the command.
        ")
        exit 1

command line program with $args:
    $searchpath =
        ("\$(NOMSU PACKAGEPATH)\$" for $ in {"?.lua", "?/init.lua", "?.nom", "?/init.nom"})
            joined with ";"
    
    for $package_name in $args.extras:
        $path = ($package.searchpath $package_name $searchpath "/")
        unless $path:
            say "Sorry, couldn't find \$package_name in \$(NOMSU PACKAGEPATH)"
            exit 1
        $path = ($path, with "/init%.nom" -> "")
        unless ((ask "Do you want to delete \($path)? [Y/n] ") == "n"):
            run command "rm -rv \$path"