diff --git a/bashbirds.sh b/bashbirds.sh index 5786625..0269a58 100755 --- a/bashbirds.sh +++ b/bashbirds.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="v1.0" +VERSION="v1.1" red="\033[1;31m" greenbold="\033[1;32m" @@ -42,6 +42,19 @@ LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNot echo -e "${yellowbold}Bashbird${reset} $VERSION\n" +### Help Function: +Help() { + echo "Syntax: birds.sh [OPTION]" + echo "Example: birds.sh -b buse" + echo + echo "Options:" + echo "-b -b , -b all." + echo "-h Print this Help." + echo "-m Export markdown." + echo "-v Prints current version." + echo "-w Export html." +} + req2() { option=$1 @@ -60,7 +73,7 @@ req2() { #query2="SELECT * FROM liste;" query2="SELECT Francais, Autres, Latin, Anglais, Ordre, Famille, Liens FROM liste;" - result2=$(sqlite3 ./birds.db "$query2") + result2=$(sqlite3 "$ScriptWorkDir/birds.db" "$query2") #echo "$result2" i=1 @@ -255,7 +268,7 @@ req1() { request=$(echo "$request" | sed 'y/áàâäçéèêëîïìôöóùúüñÂÀÄÇÉÈÊËÎÏÔÖÙÜÑ/aaaaceeeeiiiooouuunAAACEEEEIIOOUUN/') query1="SELECT * FROM liste WHERE Fra LIKE \"%$request%\" OR Aut LIKE \"%$request%\" OR Latin LIKE \"%$request%\""; - result1=$(sqlite3 ./birds.db "$query1") + result1=$(sqlite3 "$ScriptWorkDir/birds.db" "$query1") if [ -n "$result1" ]; then array2=() @@ -358,24 +371,21 @@ if [[ "$VERSION" != "$LatestRelease" ]] ; then fi fi - -if [ ! -f ./birds.db ]; then +### Database is present or not ? +if [ ! -f "$ScriptWorkDir/birds.db" ]; then echo -e "${red}No database found !${reset}" exit 1 -fi -### Help Function: -Help() { - echo "Syntax: birds.sh [OPTION]" - echo "Example: birds.sh -b buse" - echo - echo "Options:" - echo "-b -b , -b all." - echo "-h Print this Help." - echo "-m Export markdown." - echo "-v Prints current version." - echo "-w Export html." -} +else + query="SELECT COUNT(Francais) FROM liste"; + result5=$(sqlite3 "$ScriptWorkDir/birds.db" "$query") + + if [ -n "$result5" ]; then + echo -e "\n${bold}A birds database that return keywords for Lightroom.${reset}" + echo -e "$result5 birds founds in database...\n" + Help + fi +fi while getopts "b:hmw" options; do case "${options}" in