~hnaguski/vtt

cc011205cd46db16faa51ba6856ca4529d525bee — Henry Naguski 7 months ago b3072a8 master
make vts output formatting work with bsd column
1 files changed, 5 insertions(+), 2 deletions(-)

M vts
M vts => vts +5 -2
@@ 19,7 19,8 @@ usage() {
listall() {
	# selects all names and descriptions from all the packs in all the
	# categories, then pipes the output to column to format it nicely
	jq -r '.categories[].packs[] | "\(.name);\(.description)"' "$VTT_CACHE/$VTT_REMOTE/rpcategories-$VTT_MCVER.json" | column -td -s ";" -N "name,desc" -T desc
	jq -r '.categories[].packs[] | "\(.name);\(.description)"' "$VTT_CACHE/$VTT_REMOTE/rpcategories-$VTT_MCVER.json" | column -t -s ';' | cut -c 1-"$COLUMNS"

}

search() {


@@ 27,11 28,13 @@ search() {
	# could be neat to also print the category for each of these, but maybe only
	# do this in 'info'
	jq -r '.categories[].packs[] | select((.name | test("'"$1"'"; "i")) or (.description | test("'"$1"'"; "i"))) | "\(.name);\(.description)"' \
		"$VTT_CACHE/$VTT_REMOTE/rpcategories-$VTT_MCVER.json" | column -td -s ";" -N "name,desc" -T desc
		"$VTT_CACHE/$VTT_REMOTE/rpcategories-$VTT_MCVER.json" | column -t -s ';' | cut -c 1-"$COLUMNS"
}

[ -z "$1" ] && usage 1

# some shells set COLUMNS already
COLUMNS="${COLUMNS:-$(stty size | awk '{print $2}')}"
while getopts ":ah:" arg; do
	case $arg in
	a) # list name and description of every pack