From 28c7e097dbc79c51fce577f61312b495487b7670 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 15 Jun 2023 20:13:39 +0900 Subject: [PATCH] Replace deprecated fetch with http get (#530) Applied in https://github.com/nushell/nushell/pull/7796 --- sourced/cool-oneliners/dict.nu | 2 +- sourced/gitlab/gitlab.nu | 2 +- sourced/misc/nu_defs.nu | 4 ++-- sourced/update_hosts.nu | 2 +- sourced/webscraping/shell_stars.nu | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sourced/cool-oneliners/dict.nu b/sourced/cool-oneliners/dict.nu index c11b109e..563fdf9d 100644 --- a/sourced/cool-oneliners/dict.nu +++ b/sourced/cool-oneliners/dict.nu @@ -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 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) if $w == "No Definitions Found" { diff --git a/sourced/gitlab/gitlab.nu b/sourced/gitlab/gitlab.nu index 8d3573c9..b69c67da 100644 --- a/sourced/gitlab/gitlab.nu +++ b/sourced/gitlab/gitlab.nu @@ -7,7 +7,7 @@ def call-gitlab [ ...args: 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 def main [ diff --git a/sourced/misc/nu_defs.nu b/sourced/misc/nu_defs.nu index b276496b..cc838dc9 100644 --- a/sourced/misc/nu_defs.nu +++ b/sourced/misc/nu_defs.nu @@ -310,7 +310,7 @@ def mbitly [longurl] { let username = "user" 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 | 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)" - fetch $url | get responseData | get translatedText + http get $url | get responseData | get translatedText } } diff --git a/sourced/update_hosts.nu b/sourced/update_hosts.nu index a9b2ce39..eb98155f 100644 --- a/sourced/update_hosts.nu +++ b/sourced/update_hosts.nu @@ -26,7 +26,7 @@ module hosts { let whitelisted = "(" + ($WHITELIST | str join "|") + ")" let pattern = ($"0.0.0.0.*($whitelisted).*$") let OLD_FILE = "/etc/hosts" - let TMP_FILE = (fetch $LINK | lines) + let TMP_FILE = (http get $LINK | lines) if ($env.LAST_EXIT_CODE == 0) { let OLD_HEAD = (open $OLD_FILE --raw | lines | first 8 | last 3) diff --git a/sourced/webscraping/shell_stars.nu b/sourced/webscraping/shell_stars.nu index 94d37f16..9fc23685 100644 --- a/sourced/webscraping/shell_stars.nu +++ b/sourced/webscraping/shell_stars.nu @@ -35,7 +35,7 @@ $shell_list | each { |r| print "" } else { 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)" [[shell repo stars]; [($r.name) ($r.repo) ($count)]] }