aboutsummaryrefslogtreecommitdiff
path: root/lib/tools/uninstall.nom
blob: f5dbaa39ee28c2fd588d271235c2d51ce909930e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env nomsu -V7.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 =
        [:
            for $ in ["?.lua", "?/init.lua", "?.nom", "?/init.nom"]:
                add "\$(NOMSU PACKAGEPATH)\$"
        ], joined with ";"
    
    for $package_name in $args.extras:
        $path = ($package.searchpath $package_name $package.nomsupath "/")
        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"