summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xoedquery.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/oedquery.sh b/oedquery.sh
index 6bdad65..50e9fd2 100755
--- a/oedquery.sh
+++ b/oedquery.sh
@@ -16,6 +16,10 @@ _jq() {
_getdata() {
# Take everything after final space as the requested word (assuming everything before the last space is a flag)
word=$(echo $word | sed 's/.* //')
+ if [[ "$word" = "null" ]]
+ then
+ echo "Missing word. Usage: !oed [option] [word]. Use -h for help."
+ fi
lemmasUrl=https://od-api.oxforddictionaries.com/api/v2/lemmas/$language/$word
# get lemmas to link an inflected form back to its headword (required to get definition)
result=$(eval curl $OPTS $lemmasUrl)
@@ -94,7 +98,12 @@ _thes() {
_audio() {
_getdata
output=$(echo "${result}" | jq '.results[0].lexicalEntries[0].entries[0].pronunciations[0].audioFile' | tr -d \")
- echo $output
+ if [[ "$output" != "null" ]]
+ then
+ echo $output
+ else
+ echo "No audio file found."
+ fi
exit 0
}
@@ -109,6 +118,7 @@ _wod() {
# Remove surrounding quotes
definition=$(echo "${definition:1: -1}")
lexicalCategory=$(echo "${lexicalCategory:1: -1}")
+ # Don't output example sentence if not returned from OED
if [[ "$examplePhrase" != "null" ]]
then
output=$word" - "$lexicalCategory" - "$definition" - "$examplePhrase
@@ -120,7 +130,7 @@ _wod() {
}
_help() {
- echo "Usage: !oeddefine [option] [word]. Options: -h help -t thesaurus -e etymology -d define -a audio -s source"
+ echo "Usage: !oed [option] [word]. Options: -h help -t thesaurus -e etymology -d define -a audio -s source"
exit 0
}