Refactoring Code
This commit is contained in:
77
src/base.sh
77
src/base.sh
@@ -1,31 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! "$BASH_VERSION" ] ; then
|
||||
bash $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wxRed=$(tput setaf 196)
|
||||
wxGreen=$(tput setaf 46)
|
||||
wxYellow=$(tput setaf 226)
|
||||
wxBlue=$(tput setaf 21)
|
||||
wxPurple=$(tput setaf 165)
|
||||
wxTurquoise=$(tput setaf 14)
|
||||
wxPink=$(tput setaf 198)
|
||||
wxOrange=$(tput setaf 202)
|
||||
wxUnderline=$(tput smul)
|
||||
wxBold=$(tput bold)
|
||||
wxNormal=$(tput sgr0)
|
||||
#if [ ! "$BASH_VERSION" ] ; then
|
||||
# bash $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
declare -Ax args
|
||||
declare -Ax config
|
||||
declare -Ax messages
|
||||
|
||||
{{ FUNCTIONS }}
|
||||
{{ UI }}
|
||||
{{ COMMANDS }}
|
||||
|
||||
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
|
||||
i=1
|
||||
while [[ "$1" != "" ]]
|
||||
do
|
||||
case $1 in
|
||||
--*)
|
||||
key="${1%%=*}"
|
||||
value="${1#*=}"
|
||||
|
||||
if [[ "$value" == "$key" ]]
|
||||
then
|
||||
shift
|
||||
value="$1"
|
||||
fi
|
||||
|
||||
if [[ -z $value ]]
|
||||
then
|
||||
value=true
|
||||
fi
|
||||
|
||||
args["${key#--}"]="$value"
|
||||
;;
|
||||
-*)
|
||||
key="${1%=*}"
|
||||
value="${1#*=}"
|
||||
|
||||
if [[ "$value" == "$key" ]]
|
||||
then
|
||||
shift
|
||||
value="$1"
|
||||
fi
|
||||
|
||||
if [[ -z $value ]]
|
||||
then
|
||||
value=true
|
||||
fi
|
||||
|
||||
args["${key#-}"]="$value"
|
||||
;;
|
||||
*)
|
||||
args["$i"]="${1%%=*}"
|
||||
i=$((i + 1))
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ ! -z ${args['1']} ]] && [[ $(type -t wx-${args['1']}) == function ]]
|
||||
then
|
||||
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||
wx-${args['1']}
|
||||
else
|
||||
wx-welcome
|
||||
wx-welcome
|
||||
fi
|
||||
wx-stop
|
||||
wxi-stop
|
||||
|
||||
Reference in New Issue
Block a user