about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclassabbyamp <void@placeviolette.net>2024-02-06 12:41:51 -0800
committerLeah Neukirchen <leah@vuxu.org>2024-02-07 23:50:27 +0100
commitee7c68cef40403cf654ecf4a8c55a348be28fd90 (patch)
treee7e6f0a64c74321bdbdefb70439bbf38e4619b21
parent45cf3ff916a551f42c6bcb2e2101042b58cd0ef8 (diff)
downloadxtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.tar.gz
xtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.tar.xz
xtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.zip
xls: show tree(1)-style output if called as xtree
Closes: #321 [via git-merge-pr]
-rw-r--r--Makefile2
-rw-r--r--_xtools3
-rwxr-xr-xxls17
-rw-r--r--xtools.18
l---------xtree1
5 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 63fbf37..507cb2e 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ all:
 
 install:
 	for f in x*[!~1]; do install -Dm0755 $$f $(DESTDIR)$(PREFIX)/bin/$$f; done
+	# install dereferences symlinks
+	ln -sf xls $(DESTDIR)$(PREFIX)/bin/xtree
 	install -Dm644 _xtools $(DESTDIR)/$(PREFIX)/share/zsh/site-functions/_xtools
 	install -Dm644 -t $(DESTDIR)/$(PREFIX)/share/fish/vendor_completions.d -D fish/completions/*
 	install -Dm644 -t $(DESTDIR)/$(PREFIX)/share/fish/vendor_functions.d -D fish/functions/*
diff --git a/_xtools b/_xtools
index 905f6c0..8284ed0 100644
--- a/_xtools
+++ b/_xtools
@@ -1,4 +1,4 @@
-#compdef xbuildbarf xbulk xbump xchangelog xcheckrestart xdbg xdiff xdowngrade xgensum xgrep xi xilog xlg xlocate xlog xls xmypkgs xoptdiff xpkg xpkgdiff xq xrecent xrevbump xrevshlib xsrc xsubpkg
+#compdef xbuildbarf xbulk xbump xchangelog xcheckrestart xdbg xdiff xdowngrade xgensum xgrep xi xilog xlg xlocate xlog xls xmypkgs xoptdiff xpkg xpkgdiff xq xrecent xrevbump xrevshlib xsrc xsubpkg xtree
 
 _xbps  # force autoload
 
@@ -159,6 +159,7 @@ _xtools() {
 		xrevshlib) _xtools_one_template "$@";;
 		xsrc) _xtools_one_template "$@";;
 		xsubpkg) _xsubpkg "$@";;
+		xtree) _xtools_just_packages "$@";;
 	esac
 }
 
diff --git a/xls b/xls
index 3fdd090..08bdcca 100755
--- a/xls
+++ b/xls
@@ -1,5 +1,17 @@
-#!/bin/sh
+#!/bin/bash
 # xls PKGS... - list files contained in PKGS (including binpkgs)
+# xtree PKGS... - list files contained in PKGS (including binpkgs) in a tree-style format
+
+PROG="${0##*/}"
+FILTER="cat"
+
+if [ "$PROG" = xtree ]; then
+	if type tree >/dev/null; then
+		FILTER="tree --noreport --fflinks --fromfile ."
+	else
+		echo "$PROG: could not find tree, falling back to xls" >&2
+	fi
+fi
 
 BRANCH=$(git symbolic-ref -q --short HEAD 2>/dev/null)
 if [ -n "$XBPS_HOSTDIR" ]; then
@@ -21,6 +33,7 @@ ADDREPO="
 	--repository=$XBPS_BINPKGS/debug
 "
 
+set -o pipefail
 for pkg; do
-	xbps-query $ADDREPO -f $pkg
+	xbps-query $ADDREPO -f $pkg | $FILTER
 done
diff --git a/xtools.1 b/xtools.1
index 4f5eeac..98de74d 100644
--- a/xtools.1
+++ b/xtools.1
@@ -244,6 +244,14 @@ Ar pkg
 .It Fl m
 only print main package
 .El
+.It Nm xtree Ar pkg ...
+.Nd list files contained in pkg (including binpkgs) in a
+.Xr tree 1
+-style format.
+If
+.Nm tree
+is not installed, falls back to
+.Nm xls .
 .It Nm xuname
 .Nd display system info relevant for debugging Void
 .It Nm xvoidstrap Ar dir Op Ar packages
diff --git a/xtree b/xtree
new file mode 120000
index 0000000..286d1cf
--- /dev/null
+++ b/xtree
@@ -0,0 +1 @@
+xls
\ No newline at end of file