pursue --help implementation

This commit is contained in:
fatalerrors
2026-03-10 10:52:17 +01:00
parent 2ece711e1a
commit 6c895b509a

View File

@@ -39,6 +39,27 @@
# Usage: ver # Usage: ver
ver() ver()
{ {
local PARSED=$(getopt -o h --long help -n 'ver' -- "$@")
if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"ver --help\" to display usage."
return 1
fi
eval set -- "$PARSED"
case "$1" in
-h|--help)
printf "ver: Display the current profile version.\nUsage: ver\n"
return 0
;;
--)
shift
break
;;
*)
disp E "Invalid options, use \"ver --help\" to display usage."
return 1
;;
esac
[[ -z $PROFVERSION ]] && \ [[ -z $PROFVERSION ]] && \
disp W "No version defined. Profile is probably badly installed." && \ disp W "No version defined. Profile is probably badly installed." && \
return 1 return 1
@@ -53,7 +74,28 @@ export -f ver
# Usage: meteo [city1 city2 ...] # Usage: meteo [city1 city2 ...]
meteo() meteo()
{ {
local encoded cities=("$@") local PARSED=$(getopt -o h --long help -n 'meteo' -- "$@")
if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"meteo --help\" to display usage."
return 1
fi
eval set -- "$PARSED"
case "$1" in
-h|--help)
printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n"
return 0
;;
--)
shift
break
;;
*)
disp E "Invalid options, use \"meteo --help\" to display usage."
return 1
;;
esac
local cities=("$@")
[[ $# -eq 0 ]] && cities=("$DEFAULT_CITY") [[ $# -eq 0 ]] && cities=("$DEFAULT_CITY")
for city in "${cities[@]}"; do for city in "${cities[@]}"; do
@@ -71,7 +113,27 @@ export -f meteo
# Usage: showinfo # Usage: showinfo
showinfo() showinfo()
{ {
echo -e "\n" local PARSED=$(getopt -o h --long help -n 'showinfo' -- "$@")
if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"showinfo --help\" to display usage."
return 1
fi
eval set -- "$PARSED"
case "$1" in
-h|--help)
printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n"
return 0
;;
--)
shift
break
;;
*)
disp E "Invalid options, use \"showinfo --help\" to display usage."
return 1
;;
esac
printf "\n"
if command -v figlet >/dev/null 2>&1; then if command -v figlet >/dev/null 2>&1; then
if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then
local figopt="-f ansi_shadow" local figopt="-f ansi_shadow"
@@ -94,11 +156,11 @@ showinfo()
if [[ -s /etc/os-release ]]; then if [[ -s /etc/os-release ]]; then
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /etc/os-release . /etc/os-release
echo "$NAME $VERSION" printf "$NAME $VERSION\n"
else else
cat /proc/version cat /proc/version
fi fi
echo "Uptime: $(uptime -p)" printf "Uptime: $(uptime -p)\n"
) )
fi fi
} }
@@ -106,4 +168,5 @@ export -f showinfo
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
load_conf info
# EOF # EOF