From 6419cc14ede46506710d9d7dd74e6daa58337c8c Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Mon, 7 Dec 2020 16:51:25 +0100
Subject: [PATCH] Update help and show commands

---
 stpkg | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/stpkg b/stpkg
index b892d3e..0a75454 100755
--- a/stpkg
+++ b/stpkg
@@ -49,8 +49,8 @@ require() {
     for CMD in $*; do
         local __cmd=`which $1`
         [ $? -ne 0 ] && die "Failed to find the '$1' command"
-        alias $1=$__cmd
-        REQUIREMENTS="$1 $REQUIREMENTS"
+        alias $CMD=$__cmd
+        REQUIREMENTS="$CMD $REQUIREMENTS"
     done
 }
 require \
@@ -95,15 +95,15 @@ usage() {
     echo `__bold "$BASE_NAME usage:"`
     BASE_NAME=`__green "$BASE_NAME"`
 cat << EOF
-    $BASE_NAME -install `__yellow "[-sshfs 'username@server' -local mnt_point] [install_path]"`
+    $BASE_NAME -install [`__yellow "-sshfs 'username@server' -local mnt_point"`] [`__yellow "install_path"`]
     $BASE_NAME show
     $BASE_NAME help
     $BASE_NAME update
-    $BASE_NAME list `__yellow "[-p -e -np] [bash_regex]"`
-    $BASE_NAME add|del `__yellow "<pack>"`
-    $BASE_NAME pack `__yellow "[-t token] [name] <pack_folder>"`
-    $BASE_NAME display `__yellow "[-dl folder] <pack_name> [sticker_regex]"`
-    $BASE_NAME edit `__yellow "<pack_name>"` add|del `__yellow "<sticker> [file]"`
+    $BASE_NAME list [`__yellow "-p -e -np"`] [`__yellow "bash_regex"`]
+    $BASE_NAME add|del <`__yellow "pack"`>
+    $BASE_NAME pack [`__yellow "-t token"`] [`__yellow "name"`] <`__yellow "pack_folder"`>
+    $BASE_NAME display [`__yellow "-dl folder"`] <`__yellow "pack_name"`> [`__yellow "sticker_regex"`]
+    $BASE_NAME edit <`__yellow "pack_name"`> add|del <`__yellow "sticker"`> [`__yellow "file"`]
 
 `__bold Flags:`
     `__yellow "-e"` / `__yellow "-ne"`    The pack is enabled / disabled
@@ -120,14 +120,14 @@ cat << EOF
     `__green STPKG_HOMESERV` [`__italic 'homeserv'`]  The Matrix home server. [$(__yellow `__italic 'iiens.net'`)]
 
 `__bold Notes:`
-    The `__italic "'stpkg -install [path]'"` must be called only once. The default install
-    path is `__italic "'~/html/stickerpicker'"`. This command will give you a `__italic STPKG_INSTALL`
-    and a `__italic STPKG_BASE` env that you must put in your bashrc for the rest of the
+    The `__italic "$(__yellow 'stpkg -install [path]')"` must be called only once. The default install
+    path is `__italic "$(__yellow '~/html/stickerpicker')"`. This command will give you a `__italic $(__yellow STPKG_INSTALL)`
+    and a `__italic $(__yellow STPKG_BASE)` env that you must put in your bashrc for the rest of the
     stpkg commands to work.
 
 `__bold Requirements:`
-    The stpkg command requires 'egrep'. If 'egrep' is not found, 'grep' will be
-    used. Here is a list of all the requirements:
+    The stpkg command requires `__italic $(__yellow 'egrep')`. If `__italic $(__yellow 'egrep')` is not found, `__italic $(__yellow 'grep')` will be
+    used instead. Here is a list of all the requirements:
     $REQUIREMENTS
 EOF
     exit 0
@@ -334,7 +334,7 @@ __show() {
     if [ "x$STPKG_SSHFS" = "xyes" ]; then
 cat << EOF
 `__bold stpkg with sshfs install:`
-    sshfs target is mounted:  `[ -d $STPKG_INSTALL ] && __green 'yes' || __yellow 'no'`
+    sshfs   `[ -d $STPKG_INSTALL ] && __green 'mounted' || __yellow 'umounted'`
 EOF
     fi
 
@@ -352,13 +352,19 @@ EOF
 
 cat << EOF
 `__bold stpkg options and variables:`
-    `__green STPKG_INSTALL`             `__italic $STPKG_INSTALL`
-    `__green STPKG_BASE`                `__italic $STPKG_BASE`
-    `__green STPKG_COLORS`              `__italic $($COLOR_STCOLOR $STPKG_COLORS)`
-    `__green STPKG_NO_MSG`              `__italic $($COLOR_STNOMSG $STPKG_NO_MSG)`
-    `__green STPKG_HOMESERV`            `__italic $STPKG_HOMESERV`
-    `__green STPKG_TOKEN`               $TOKEN
+    `__green STPKG_INSTALL`    `__italic $STPKG_INSTALL`
+    `__green STPKG_BASE`       `__italic $STPKG_BASE`
+    `__green STPKG_COLORS`     `__italic $($COLOR_STCOLOR $STPKG_COLORS)`
+    `__green STPKG_NO_MSG`     `__italic $($COLOR_STNOMSG $STPKG_NO_MSG)`
+    `__green STPKG_HOMESERV`   `__italic $STPKG_HOMESERV`
+    `__green STPKG_TOKEN`      $TOKEN
+`__bold aliased commands due to the '"require"' function:`
 EOF
+    for CMD in $REQUIREMENTS; do
+        echo -e " `__green $CMD` `which $CMD`"
+    done | sort | column -t | while IFS= read LINE; do
+        echo "    $LINE"
+    done
 }
 
 __update() {
-- 
GitLab