mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Update Grab
This commit is contained in:
parent
badbb77f40
commit
2b6f456c8c
24
grab.lua
24
grab.lua
|
@ -9,10 +9,17 @@ if( (#args<1 and (not options["setup"])) or options["help"]) then
|
||||||
print("Options:"
|
print("Options:"
|
||||||
.. "\n\t--cn Use mirror site in China. By default grab will download from Github."
|
.. "\n\t--cn Use mirror site in China. By default grab will download from Github."
|
||||||
.. "\n\t--help Display this help page."
|
.. "\n\t--help Display this help page."
|
||||||
.. "\n\t--setup Download some basic files for development"
|
.. "\n\t--setup Download some basic files for development."
|
||||||
|
.. "\n\t--version Display version and exit."
|
||||||
|
.. "\n\t--proxy=<Proxy File> Given a proxy file which will be loaded and returns a proxy function like: "
|
||||||
|
.. "function(RepoName: string, Branch: string ,FileAddress: string): string"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if(options["version"]) then
|
||||||
|
print("Grab v1.1")
|
||||||
|
return
|
||||||
|
end
|
||||||
local function download(url)
|
local function download(url)
|
||||||
if(component.internet==nil) then
|
if(component.internet==nil) then
|
||||||
error("This program requires an Internet card.")
|
error("This program requires an Internet card.")
|
||||||
|
@ -37,6 +44,7 @@ local function download(url)
|
||||||
return true,result,code
|
return true,result,code
|
||||||
end
|
end
|
||||||
local UrlGenerator
|
local UrlGenerator
|
||||||
|
if(not options["proxy"]) then
|
||||||
if(not options["cn"]) then
|
if(not options["cn"]) then
|
||||||
UrlGenerator=function(RepoName,Branch,FileAddress)
|
UrlGenerator=function(RepoName,Branch,FileAddress)
|
||||||
return "https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
|
return "https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
|
||||||
|
@ -46,6 +54,20 @@ else
|
||||||
return "http://kiritow.com:3000/" .. RepoName .. "/raw/" .. Branch .. "/" .. FileAddress
|
return "http://kiritow.com:3000/" .. RepoName .. "/raw/" .. Branch .. "/" .. FileAddress
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
local ok,err=pcall(function()
|
||||||
|
local f=io.open(options["proxy"],"r")
|
||||||
|
if(f==nil) then error("Proxy file not found") end
|
||||||
|
local src=f:read("a")
|
||||||
|
f:close()
|
||||||
|
local fn=load(src)
|
||||||
|
UrlGenerator=fn()
|
||||||
|
end)
|
||||||
|
if(not ok) then
|
||||||
|
print("Proxy file error: " .. err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
local files
|
local files
|
||||||
if(options["setup"]) then
|
if(options["setup"]) then
|
||||||
files={"LICENSE","checkarg.lua","libevent.lua","class.lua","util.lua"}
|
files={"LICENSE","checkarg.lua","libevent.lua","class.lua","util.lua"}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user