14 lines
394 B
Text
14 lines
394 B
Text
|
#!/usr/bin/env nu
|
||
|
|
||
|
# TODO: include fallback to alternate URL: https://latest.currency-api.pages.dev/v1
|
||
|
|
||
|
let base_url = 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1'
|
||
|
|
||
|
def main [target:string = "usd", source:string = "eur"] {
|
||
|
(http get $"($base_url)/currencies/($source).json") | get $source | get $target
|
||
|
}
|
||
|
|
||
|
def "main list" [ ] {
|
||
|
http get $"($base_url)/currencies.json"
|
||
|
}
|