mirror of https://github.com/aldy505/dotfiles.git
using Downloads instead of HTTP package
This commit is contained in:
parent
f8218dc843
commit
65ebd65574
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue