Added `list' command.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 2 Apr 2018 01:43:48 +0000 (03:43 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 2 Apr 2018 01:43:48 +0000 (03:43 +0200)
tpkg

diff --git a/tpkg b/tpkg
index 140ed2f..319d248 100755 (executable)
--- a/tpkg
+++ b/tpkg
@@ -318,6 +318,23 @@ def cmd_uninstall(argv):
     uninstall(prefix.use, pkgname)
 cmds["uninstall"] = cmd_uninstall
 
+def cmd_list(argv):
+    def usage(out):
+        out.write("usage: tpkg list NAME\n")
+    opts, args = getopt.getopt(argv, "")
+    if len(args) < 1:
+        usage(sys.stderr)
+        sys.exit(1)
+    pkgname = args[0]
+    try:
+        files = prefix.use.pkgfiles(pkgname)
+    except KeyError:
+        sys.stderr.write("tpkg: %s: no such package\n" % (pkgname))
+        sys.exit(1)
+    for fn in files:
+        sys.stdout.write("%s\n" % pj(prefix.use.root, fn))
+cmds["list"] = cmd_list
+
 def usage(file):
     file.write("usage:\ttpkg help\n")
 cmds["help"] = lambda argv: usage(sys.stdout)