diff options
-rw-r--r-- | oedquery.conf | 10 | ||||
-rwxr-xr-x | oedquery.sh | 22 |
2 files changed, 28 insertions, 4 deletions
diff --git a/oedquery.conf b/oedquery.conf new file mode 100644 index 0000000..a98c46d --- /dev/null +++ b/oedquery.conf @@ -0,0 +1,10 @@ +# Example config + +# Enter your OED API ID and key here +appId= +appKey= + +# Enter desired language here - supported languages: https://developer.oxforddictionaries.com/documentation/languages +language=en-gb +# Desired max synonyms - some entries have a crazy number of them +maxSynonyms=10 diff --git a/oedquery.sh b/oedquery.sh index 043467f..12811c8 100755 --- a/oedquery.sh +++ b/oedquery.sh @@ -2,11 +2,25 @@ read word word=$(echo $word | tr '[:upper:]' '[:lower:]') -appId= -appKey= -language=en-gb +# Create array of variable to read from config file +config=( + appId + appKey + language + maxSynonyms +) +# curl options OPTS='--silent -L -H "app_id: $appId" -H "app_key: $appKey"' -maxSynonyms=10 + +while read line +do + # If config file variable doesn't match variable in config array then ignore it. + if [[ " ${config[@]} " =~ " $(echo "$line" | cut -d '=' -f 1) " ]] + then + # Declare variables + eval $(echo "$line" | cut -d '=' -f 1)=$(echo "$line" | cut -d '=' -f 2-) +fi +done < oedquery.conf # function to provide data to a for loop _jq() { |