Return to repo list

stctpw

Portage-compatible patch maker for suckless tools.
Return to HMagellan.com

commit 8899872c0f94023c2f014c81b3ae5d94139d0a9e
parent 6b972ea4fcad4d34fe65e162fd431a4d7022305f
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 28 Jul 2020 14:01:36 -0500

help option and some function started

Diffstat:
Mstctpw.sh | 36++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/stctpw.sh b/stctpw.sh @@ -9,6 +9,28 @@ FETCHWEB=0 INSTALLPATCH=0 NUMARGS=0 +# Functions +displayhelp() { + printf "Usage: stctpw.sh [OPTIONS] [ARGUMENT]\n" + printf "Create a diff file for a suckless program's config.h.\n\n" + printf "Mandatory options for long arguments are mandatory for short arguments too:\n" + printf "\t-f=[FILE]\t\tThe file to use to create a patch.\n" + printf "\t-w, --web\t\tDon't look for local distfiles; fetch them from the web instead.\n" + printf "\t-i, --install\t\tInstall the patch in the proper location (/etc/portage/patches/{CATEGORY}/{P}).\n" + printf "\t--help\t\t\tDisplay this help text.\n\n" + printf "Arguments should be lowercase names of suckless programs. The currently supported arguments are:\n" + printf "\tst\t- Simple Terminal\n" + printf "\tdwm\t- Dynamic Window Manager\n" + printf "\tdmenu\t- Dmenu\n" + printf "Copyright (c) 2020 Erik Letson, all rights reserved\n" + printf "This program is released under the MIT"'\\'"Expat license. See LICENSE file for details.\n" + return 0 +} + +multidistfileprompt() { + return 0 +} + # Opts while [[ "$#" -gt 0 ]]; do case $1 in @@ -18,6 +40,9 @@ while [[ "$#" -gt 0 ]]; do FETCHWEB=1 ;; -i|--install) INSTALLPATCH=1 ;; + --help) + displayhelp + exit 0 ;; *) ARG=$1 NUMARGS=$NUMARGS+1 @@ -31,7 +56,8 @@ while [[ "$#" -gt 0 ]]; do done if [[ -z $ARG ]]; then - echo "No argument chosen!" + printf "No argument passed. Please provide the name of the suckless program you want to generate a patch for.\n" + printf "Try 'stctpw.sh --help' for more information.\n" exit 1 fi @@ -42,5 +68,11 @@ cp $MODFILE /var/tmp/stctpw # Get the archive (has potential interactive elements) if [[ $FETCHWEB -ne 1 ]]; then - TARGETDISTFILES=$(find /var/cache/distfiles/ | grep "^/var/cache/distfiles/$ARG-") + numlines=0 + find /var/cache/distfiles/ | grep "^/var/cache/distfiles/$ARG-" | while read line; do + numlines=$numlines+1 + TARGETDISTFILES="$TARGETDISTFILES $line" + done + if [[ $numlines -ge 2 ]]; then + fi