From 19cee3a2e1cc7af20365f63548dfb21560790d2a Mon Sep 17 00:00:00 2001
From: merakor <cem@ckyln.com>
Date: Sun, 19 Apr 2020 18:47:40 +0000
Subject: kiss: implement user scripts from upstream

FossilOrigin-Name: ee011fef1c32c0dc066d933c12a450634510ae213ca3bbabad8d75ffcf5362ac
---
 kiss | 45 +++++++++++++++++++++++++++++++++------------
 1 file changed, 33 insertions(+), 12 deletions(-)

(limited to 'kiss')

diff --git a/kiss b/kiss
index 1431f7b..f08b195 100755
--- a/kiss
+++ b/kiss
@@ -128,7 +128,7 @@ pkg_find() {
         set +f
 
         for path2 in "$path/"$query; do
-            [ -d "$path2" ] && set -f -- "$@" "$path2"
+            [ -e "$path2" ] && set -f -- "$@" "$path2"
         done
     done
 
@@ -1338,19 +1338,40 @@ args() {
 
         h|help|-h|--help|'')
             log 'kiss [a|b|c|f|i|l|r|s|u|v] [pkg] [pkg] [pkg]'
-            log 'alternatives: List and swap to alternatives'
-            log 'build:        Build a package'
-            log 'checksum:     Generate checksums'
-            log 'fetch:        Fetch repositories'
-            log 'install:      Install a package'
-            log 'list:         List installed packages'
-            log 'remove:       Remove a package'
-            log 'search:       Search for a package'
-            log 'update:       Check for updates'
-            log 'version:      Package manager version'
+            log 'alternatives  List and swap to alternatives'
+            log 'build         Build a package'
+            log 'checksum      Generate checksums'
+            log 'fetch         Fetch repositories'
+            log 'install       Install a package'
+            log 'list          List installed packages'
+            log 'remove        Remove a package'
+            log 'search        Search for a package'
+            log 'update        Check for updates'
+            log 'version       Package manager version
+                '
+            log "Installed extensions (kiss-* in \$PATH)"
+
+            set --
+
+            for path in $(KISS_PATH=$PATH pkg_find kiss-* all); do
+                set -- "${path#*/kiss-}" "$@"
+                max=$((${#1} > max ? ${#1} : max))
+             done
+
+            for path do
+                 printf '\033[31;1m->\033[m %-*s ' "$max" "${path#*/kiss-}"
+                 sed -n 's/^# *//;2p' "$(command -v "kiss-$path")"
+             done | sort -uk1 >&2
+
         ;;
 
-        *) die "'kiss $action' is not a valid command" ;;
+        *)
+             util=$(KISS_PATH=$PATH pkg_find "kiss-$action"* 2>/dev/null) ||
+                 die "'kiss $action' is not a valid command"
+
+              "$util" "$@"
+         ;;
+
     esac
 }
 
-- 
cgit v1.2.3