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

Create dict.nu

This commit is contained in:
Kamil 2021-10-26 03:34:06 +00:00 committed by GitHub
parent 265a16694f
commit 04b7eb3360
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

12
cool_oneliners/dict.nu Normal file
View file

@ -0,0 +1,12 @@
#As the name suggests, the function returns you the definition and example of the sought English word
#(or breaks if it can't find the word because the API uses different columns for successful and invalid searches)
#usage: dict word
#usage: dict "word with space"
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|
select definition example
}