if [[ -z "$RAGUEL_DIR" ]]; then
if [[ -z "$BASH_SOURCE" ]]; then
RAGUEL_DIR=$(dirname $0)
else
RAGUEL_DIR=$(dirname "${BASH_SOURCE[0]}")
fi
fi
export RAGUEL_DIR="$RAGUEL_DIR/../src"
. "${RAGUEL_DIR}/checker.sh"
# then_run "<command(s)>"
RAGUEL_IF_EQUAL_STATE='true'
then_run "echo \"if RAGUEL_IF_EQUAL_STATE is 'true', then_run evals\" ;
echo \"it also evals when 'if_equal' or similar if_ succeeds\""
echo "and after its run RAGUEL_IF_EQUAL_STATE gets set to \
'$RAGUEL_IF_EQUAL_STATE' if it was 'true' before."
echo ''
# else_run "<command(s)>"
RAGUEL_IF_EQUAL_STATE='false'
else_run "echo \"if RAGUEL_IF_EQUAL_STATE is 'false', then_run evals\" ;
echo \"it also evals when 'if_equal' or similar if_ succeeds\""
echo "and after its run RAGUEL_IF_EQUAL_STATE gets set to \
'$RAGUEL_IF_EQUAL_STATE' if it was 'false' before."
echo ''
# it also has 'then_if_equal' & 'else_if_equal' for chaining if
# if_equal <arg1> <arg2>
if_equal $USER "abhishekkr" "echo 'any command run on pass & fail'"
if_equal $USER "abhishekkr" then_run "echo 'then runs on pass'"
if_equal $USER "abhishekkr" else_run "echo 'else runs if fails'"
if_equal $USER "abhishekkr"
then_run "echo 'abhishekkr is user'"
else_run "echo '$USER is user'"
echo ''
# it also has 'then_if_not_equal' & 'else_if_not_equal' for chaining if
# if_not_equal <arg1> <arg2>
if_not_equal $USER "abhishekkr" "echo 'any command run on pass & fail'"
if_not_equal $USER "abhishekkr" then_run "echo 'then runs on pass'"
if_not_equal $USER "abhishekkr" else_run "echo 'else runs if fails'"
if_not_equal $USER "abhishekkr"
then_run "echo 'abhishekkr is user'"
else_run "echo '$USER is user'"
echo ''
# all 'if_<check>' & 'if_not_<check>' have their 'then_' & 'else_' versions
# if_<check> <args, > ; then_run <task> ; if_<check> ; then_run <task>
# if_<check> <args, > ; then_run <task> ; if_<check> <...> ; end_if
#can use any of if_ if_not_ checks present in checker in pre-fixed by else_
if_not_file "$HOME/.vimrc"
then_if_not_dir "$HOME/.vim"
then_run "echo \"You don't have any VIM config in your HOME dir.\""
if_file "$HOME/.vimrc"
THE_CONFIG="$HOME/.vimrc"
else_if_dir "$HOME/.vim"
THE_CONFIG="$THE_CONFIG and $HOME/.vim"
then_run "echo 'You have VIM $THE_CONFIG config in your HOME dir.'"
if_file "$HOME/.vimrc"
then_if_dir "$HOME/.vim"
then_run "echo 'You have VIM .vimrc and .vim config in your HOME dir.'"
# it's there to close of any if_<check> chaining and make you feel better.
# end_if
if_not_dir "$HOME/.vim"
then_run "echo 'No VIM config present in Home dir.'"
else_if_dir "$HOME/.miv"
then_run "echo 'Your MIV config dir is present in Home dir'"
else_if_file "$HOME/.mivrc"
then_run "echo 'Your MIV RC is present in Home dir'"
else_if_equal 10 100
then_run "echo '10 is not 100, so what... didn't you knew.'"
else_run "echo 'nothing passed...'"
end_if
echo ''
# it also has 'then_if_not_file' & 'else_if_not_file' for chaining if
# if_file <path_to_file>
if_file "$HOME/.bashrc"
then_run "echo 'You have BASH RC file in your HOME dir.'"
else_run "echo 'No BASH RC file found in HOME dir.'"
echo ''
Check for Regular File not existing
- if_not_file, then_if_not_file, else_if_not_file
Check for Directory existing
- if_dir, then_if_dir, else_if_dir
Check for Directory not existing
- if_not_dir, then_if_not_dir, else_if_not_dir
Check for File being empty in size
- if_file_empty, then_if_file_empty, else_if_file_empty
Check for File being not empty in size
- if_not_file_empty, then_if_not_file_empty, else_if_not_file_empty
Check for File being Executable
- if_file_executable, then_if_file_executable, else_if_file_executable
Check for File being not Executable
- if_not_file_executable, then_if_not_file_executable, else_if_not_file_executable
Check for File being Writable
- if_file_writable, then_if_file_writable, else_if_file_writable
Check for File being not Writable
- if_not_file_writable, then_if_not_file_writable, else_if_not_file_writable
Check for File being SymLink
- if_link, then_if_link, else_if_link
Check for File being not SymLink
- if_not_link, then_if_not_link, else_if_not_link
# it also has 'then_if_var' & 'else_if_var' for chaining if
# if_var $VAR
if_var $HOME
then_run "echo 'Var HOME present.'"
else_run "echo 'Var HOME not present.'"
echo ''
# it also has 'then_if_not_var' & 'else_if_not_var' for chaining if
# if_not_var $VAR
if_not_var "$HOMESS"
then_run "echo 'Var HOMESS present.'"
else_run "echo 'Var HOMESS not present.'"
echo ''
# it also has 'then_if_git_latest' & 'else_if_git_latest' for chaining if
# if_git_latest $REPO_DIR
if_git_latest $REPO_DIR
then_run "echo 'Latest changes are in.'"
else_run "git pull"
echo ''
# it also has 'then_if_not_git_latest' & 'else_if_not_git_latest' for chaining if
# if_not_git_latest $REPO_DIR
if_not_git_latest $REPO_DIR
then_run "git pull"
else_run "echo 'Latest changes are in.'"
echo ''
# it also has 'then_if_cmd' & 'else_if_cmd' for chaining if
# if_cmd $COMMAND_NAME
if_cmd 'htop'
then_run "echo 'You can move ahead to use it.'"
else_run "echo 'You may install htop here.'"
echo ''
# it also has 'then_if_not_cmd' & 'else_if_not_cmd' for chaining if
# if_not_cmd $COMMAND_NAME
if_not_cmd 'htop'
then_run "echo 'You may install htop here.'"
else_run "echo 'You can move ahead to use it.'"
echo ''