print usage after argparse error
This commit is contained in:
parent
c3e2fc0850
commit
526aeeebfc
2 changed files with 15 additions and 15 deletions
File diff suppressed because one or more lines are too long
24
sf
24
sf
|
|
@ -20,16 +20,6 @@ sftm=$'\e[35m'
|
||||||
sftc=$'\e[36m'
|
sftc=$'\e[36m'
|
||||||
sftw=$'\e[97m'
|
sftw=$'\e[97m'
|
||||||
|
|
||||||
# Public output functions
|
|
||||||
function sferr {
|
|
||||||
echo "${sftbf}${sftr}ERROR${sftrs} $1"
|
|
||||||
[ -z "$2" ] && exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function sfwarn {
|
|
||||||
echo "${sftbf}${sfty}WARNING${sftrs} $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Public input functions
|
# Public input functions
|
||||||
function sfask {
|
function sfask {
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
|
|
@ -242,13 +232,22 @@ function _sfusage {
|
||||||
if [ -n "${sfextra}" ]; then
|
if [ -n "${sfextra}" ]; then
|
||||||
echo -e "\n$sfextra"
|
echo -e "\n$sfextra"
|
||||||
fi
|
fi
|
||||||
exit 0
|
}
|
||||||
|
|
||||||
|
# Public output functions
|
||||||
|
function sferr {
|
||||||
|
echo "${sftbf}${sftr}ERROR${sftrs} $1"
|
||||||
|
[ -z "$2" ] && _sfusage && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function sfwarn {
|
||||||
|
echo "${sftbf}${sfty}WARNING${sftrs} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for help flag
|
# Check for help flag
|
||||||
for a in "$@"; do
|
for a in "$@"; do
|
||||||
# Check if help flag ist set
|
# Check if help flag ist set
|
||||||
[ "$a" == "-h" ] || [ "$a" == "--help" ] && _sfusage
|
[ "$a" == "-h" ] || [ "$a" == "--help" ] && _sfusage && exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if dependencies are available
|
# Check if dependencies are available
|
||||||
|
|
@ -307,6 +306,7 @@ if [ "${#_sfpargs[@]}" -gt 0 ]; then
|
||||||
for p in "${_sfpargs[@]}"; do
|
for p in "${_sfpargs[@]}"; do
|
||||||
sferr "Positional argument ${sftbf}${p}${sftrs} missing" 0
|
sferr "Positional argument ${sftbf}${p}${sftrs} missing" 0
|
||||||
done
|
done
|
||||||
|
_sfusage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue