1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

dict.nu — added error-checking

it still could be a oneliner and acts like it, i just made the two variables to make the script more readable and debuggable
This commit is contained in:
Kamil 2021-10-26 03:59:14 +00:00 committed by GitHub
parent 04b7eb3360
commit c4361070cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,11 @@
def dict [word: string] {
let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($word|str find-replace ' ' '%20'))
fetch $link |
get meanings.definitions|
let output = (fetch $link |
rename word)
if $output.word == "No Definitions Found" {echo $output.word} {echo $output |
get meanings.definitions |
select definition example
}
}