Replace deprecated fetch with http get (#530)

Applied in https://github.com/nushell/nushell/pull/7796
This commit is contained in:
Kenichi Kamiya 2023-06-15 20:13:39 +09:00 committed by GitHub
parent 424e8d61a5
commit 28c7e097db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -3,7 +3,7 @@ def dict [...word #word(s) to query the dictionary API but they have to make sen
] { ] {
let query = ($word | str join %20) let query = ($word | str join %20)
let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20')) let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20'))
let output = (fetch $link | rename word) let output = (http get $link | rename word)
let w = ($output.word | first) let w = ($output.word | first)
if $w == "No Definitions Found" { if $w == "No Definitions Found" {

View File

@ -7,7 +7,7 @@ def call-gitlab [
...args: string ...args: string
--query: string --query: string
] { ] {
fetch -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str join)?($query)" http get -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str join)?($query)"
} }
# Search files on your GitLab server # Search files on your GitLab server
def main [ def main [

View File

@ -310,7 +310,7 @@ def mbitly [longurl] {
let username = "user" let username = "user"
let url = $"https://api-ssl.bitly.com/v3/shorten?access_token=($Accesstoken)&login=($username)&longUrl=($longurl)" let url = $"https://api-ssl.bitly.com/v3/shorten?access_token=($Accesstoken)&login=($username)&longUrl=($longurl)"
let shorturl = (fetch $url | get data | get url) let shorturl = (http get $url | get data | get url)
$shorturl $shorturl
$shorturl | xclip -sel clip $shorturl | xclip -sel clip
@ -345,7 +345,7 @@ def trans [
let url = $"https://api.mymemory.translated.net/get?q=($to_translate)&langpair=($from)%7C($to)&of=json&key=($key)&de=($user)" let url = $"https://api.mymemory.translated.net/get?q=($to_translate)&langpair=($from)%7C($to)&of=json&key=($key)&de=($user)"
fetch $url | get responseData | get translatedText http get $url | get responseData | get translatedText
} }
} }

View File

@ -26,7 +26,7 @@ module hosts {
let whitelisted = "(" + ($WHITELIST | str join "|") + ")" let whitelisted = "(" + ($WHITELIST | str join "|") + ")"
let pattern = ($"0.0.0.0.*($whitelisted).*$") let pattern = ($"0.0.0.0.*($whitelisted).*$")
let OLD_FILE = "/etc/hosts" let OLD_FILE = "/etc/hosts"
let TMP_FILE = (fetch $LINK | lines) let TMP_FILE = (http get $LINK | lines)
if ($env.LAST_EXIT_CODE == 0) { if ($env.LAST_EXIT_CODE == 0) {
let OLD_HEAD = (open $OLD_FILE --raw | lines | first 8 | last 3) let OLD_HEAD = (open $OLD_FILE --raw | lines | first 8 | last 3)

View File

@ -35,7 +35,7 @@ $shell_list | each { |r|
print "" print ""
} else { } else {
let url = $"https://api.github.com/repos/($r.repo)" let url = $"https://api.github.com/repos/($r.repo)"
let count = (fetch -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD ($url) | get stargazers_count) let count = (http get -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD ($url) | get stargazers_count)
print $" ($count)" print $" ($count)"
[[shell repo stars]; [($r.name) ($r.repo) ($count)]] [[shell repo stars]; [($r.name) ($r.repo) ($count)]]
} }