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 #!/usr/bin/env julia
import Pkg using Downloads
Pkg.add("HTTP")
using HTTP
if length(ARGS) == 0 if length(ARGS) == 0
println("please specify the gitignore template") println("please specify the gitignore template")
@ -17,16 +14,15 @@ end
template = ARGS[1] 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 if r.status != 200
println("the template specified does not exist") println("the template specified does not exist")
exit(1) exit(1)
end end
open(".gitignore", "a") do io
write(io, String(r.body))
end
println("gitignore successfully written") println("gitignore successfully written")
exit(0) exit(0)