move title check to usage
This commit is contained in:
parent
e9e08d36b6
commit
a344b7b802
1 changed files with 10 additions and 11 deletions
17
sf
17
sf
|
|
@ -18,11 +18,6 @@ sftmagenta=`echo -e "\e[35m"`
|
||||||
sftcyan=`echo -e "\e[36m"`
|
sftcyan=`echo -e "\e[36m"`
|
||||||
sftwhite=`echo -e "\e[97m"`
|
sftwhite=`echo -e "\e[97m"`
|
||||||
|
|
||||||
# Set script name if not set
|
|
||||||
if [ -z $sfname ]; then
|
|
||||||
sfname=$(basename "$0")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Internal error function
|
# Internal error function
|
||||||
function _sferr {
|
function _sferr {
|
||||||
echo -e "${sftbf}${sftred}SF PARSE ERROR${sftrst} $1"
|
echo -e "${sftbf}${sftred}SF PARSE ERROR${sftrst} $1"
|
||||||
|
|
@ -67,7 +62,7 @@ for a in "${sfargs[@]}"; do
|
||||||
# Add to positional argument arry
|
# Add to positional argument arry
|
||||||
_sfpargs+=("${_sfparsearr[0]}")
|
_sfpargs+=("${_sfparsearr[0]}")
|
||||||
|
|
||||||
# Set usage heager and description
|
# Set usage header and description
|
||||||
_sfphead="$_sfphead ${_sfparsearr[0]}"
|
_sfphead="$_sfphead ${_sfparsearr[0]}"
|
||||||
_sfpdesc="$_sfpdesc ${_sfparsearr[0]};${_sfparsearr[1]}\n"
|
_sfpdesc="$_sfpdesc ${_sfparsearr[0]};${_sfparsearr[1]}\n"
|
||||||
|
|
||||||
|
|
@ -130,7 +125,11 @@ IFS=$OLDIFS
|
||||||
|
|
||||||
# Usage function
|
# Usage function
|
||||||
function sfusage {
|
function sfusage {
|
||||||
|
if [ -z ${sfname+x} ]; then
|
||||||
|
sfname=$(basename "$0")
|
||||||
|
else
|
||||||
echo -n "Usage: $sfname"
|
echo -n "Usage: $sfname"
|
||||||
|
fi
|
||||||
if [ "$_sfodesc" != "" ]; then
|
if [ "$_sfodesc" != "" ]; then
|
||||||
echo -n " OPTIONS"
|
echo -n " OPTIONS"
|
||||||
fi
|
fi
|
||||||
|
|
@ -150,15 +149,15 @@ function sfusage {
|
||||||
echo -e "\nEXAMPLES"
|
echo -e "\nEXAMPLES"
|
||||||
echo -e "$_sfexamples" | column -c 80 -s ";" -t -W 2
|
echo -e "$_sfexamples" | column -c 80 -s ";" -t -W 2
|
||||||
fi
|
fi
|
||||||
if [ ! -z ${sfextrausage+x} ]; then
|
if [ ! -z ${sfextra+x} ]; then
|
||||||
echo -e "\n$sfextrausage"
|
echo -e "\n$sfextra"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for help flag
|
# Check for help flag
|
||||||
for a in "$@"; do
|
for a in "$@"; do
|
||||||
# Check if help
|
# Check if help flag ist set
|
||||||
if [ "$a" == "-h" ] || [ "$a" == "--help" ]; then
|
if [ "$a" == "-h" ] || [ "$a" == "--help" ]; then
|
||||||
sfusage
|
sfusage
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue