1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 15:17:47 +00:00

Update dict.nu

Wrote --help, works without quotation marks
This commit is contained in:
Kamil 2021-12-02 16:14:06 +00:00 committed by GitHub
parent 6ab6634764
commit 71b9df0ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,11 +1,8 @@
#As the name suggests, the function returns you the definition and example of the sought English word # Function querying free online English dictionary API for definition of given word(s)
#(or breaks if it can't find the word because the API uses different columns for successful and invalid searches) def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs"
] {
#usage: dict word let query = ($word | str collect %20)
#usage: dict "word with space" let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($query|str find-replace ' ' '%20'))
def dict [word: string] {
let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($word|str find-replace ' ' '%20'))
let output = (fetch $link | let output = (fetch $link |
rename word) rename word)
let w = ($output.word | first) let w = ($output.word | first)