using Downloads instead of HTTP package

This commit is contained in:
Reinaldy Rafli 2021-09-15 12:30:02 +07:00
parent f8218dc843
commit 65ebd65574
No known key found for this signature in database
GPG Key ID: CFDB9400255D8CB6
1 changed files with 5 additions and 9 deletions

View File

@ -1,9 +1,6 @@
#!/usr/bin/env julia
import Pkg
Pkg.add("HTTP")
using HTTP
using Downloads
if length(ARGS) == 0
println("please specify the gitignore template")
@ -17,16 +14,15 @@ end
template = ARGS[1]
r = HTTP.request("GET", "https://www.toptal.com/developers/gitignore/api/$template")
r = Downloads.request(
"https://www.toptal.com/developers/gitignore/api/$template";
method = "GET", throw = false, output = ".gitignore",
)
if r.status != 200
println("the template specified does not exist")
exit(1)
end
open(".gitignore", "a") do io
write(io, String(r.body))
end
println("gitignore successfully written")
exit(0)