diff options
author | ars <asav1410@gmail.com> | 2020-10-20 19:48:22 +0100 |
---|---|---|
committer | ars <asav1410@gmail.com> | 2020-10-20 19:48:22 +0100 |
commit | 013b44bf90243a0fdc4233ed8730815338886bd6 (patch) | |
tree | 6097d6a7330ab8f4086944225bf4bfaeb56a9fa2 | |
parent | 9bd1d4fb7d0be7757c34023ee8cd140a52ff7079 (diff) |
Read variables from conf file. Add example conf file.
-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() { |