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:
parent
04b7eb3360
commit
c4361070cc
1 changed files with 6 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue