Browse Source

new algorithm to find commands

pull/1333/head
UltimateByte 8 years ago
committed by GitHub
parent
commit
a49de6bcbd
  1. 27
      lgsm/functions/core_getopt.sh

27
lgsm/functions/core_getopt.sh

@ -122,13 +122,10 @@ for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
done done
done done
### Check if user command exists or run the command # Shows LinuxGSM usage
if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then fn_opt_usage(){
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo -e ""
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
@ -143,7 +140,16 @@ if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then
fi fi
done done
} | column -s $'\t' -t } | column -s $'\t' -t
else core_exit.sh
}
### Check if user commands exist and run corresponding scripts, or display script usage
if [ -z "${getopt}" ]; then
fn_opt_usage
fi
# Command exists
for i in "${optcommands[@]}"; do
if [ "${i}" == "${getopt}" ] ; then
# Seek and run command # Seek and run command
index="0" index="0"
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
@ -156,6 +162,13 @@ else
fi fi
done done
done done
break
core_exit.sh
fi fi
done
# If we're executing this, it means command was not found
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fn_opt_usage
core_exit.sh core_exit.sh

Loading…
Cancel
Save