mirror of
https://github.com/aminnairi/dotfiles.git
synced 2026-09-14 13:22:13 +02:00
displaying the help with usages examples whenever an error occurred
This commit is contained in:
@@ -19,12 +19,14 @@ ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST=6
|
|||||||
if [[ "$(id -u)" -eq 0 ]]
|
if [[ "$(id -u)" -eq 0 ]]
|
||||||
then
|
then
|
||||||
echo "Please, run this script as user"
|
echo "Please, run this script as user"
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_ROOT
|
exit $ERROR_BECAUSE_ROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -x $(command -v pacman) ]]
|
if [[ ! -x $(command -v pacman) ]]
|
||||||
then
|
then
|
||||||
echo "Please, use this script with an Arch Linux operating system."
|
echo "Please, use this script with an Arch Linux operating system."
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_NOT_ARCH_LINUX
|
exit $ERROR_BECAUSE_NOT_ARCH_LINUX
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ then
|
|||||||
then
|
then
|
||||||
|
|
||||||
echo "Installion failed."
|
echo "Installion failed."
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED
|
exit $ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -42,6 +45,7 @@ fi
|
|||||||
if [[ $# -gt 1 ]]
|
if [[ $# -gt 1 ]]
|
||||||
then
|
then
|
||||||
echo "Too much arguments provided."
|
echo "Too much arguments provided."
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_TOO_MUCH_ARGUMENTS_PROVDED
|
exit $ERROR_BECAUSE_TOO_MUCH_ARGUMENTS_PROVDED
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -73,6 +77,7 @@ then
|
|||||||
if [[ -z $choosen_playbook_path ]]
|
if [[ -z $choosen_playbook_path ]]
|
||||||
then
|
then
|
||||||
echo "Error: invalid index."
|
echo "Error: invalid index."
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND
|
exit $ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -80,6 +85,7 @@ fi
|
|||||||
if [[ ! -f $choosen_playbook_path ]]
|
if [[ ! -f $choosen_playbook_path ]]
|
||||||
then
|
then
|
||||||
echo "Error: playbook path $choosen_playbook_path does not exist on the file system."
|
echo "Error: playbook path $choosen_playbook_path does not exist on the file system."
|
||||||
|
display_help
|
||||||
exit $ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST
|
exit $ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user