git goodest
This commit is contained in:
parent
1b0a016222
commit
8355faffad
@ -51,7 +51,7 @@ local function download_file(repo_path, local_path)
|
||||
if not result then
|
||||
print()
|
||||
printError(err)
|
||||
return
|
||||
return false
|
||||
end
|
||||
|
||||
local f = fs.open(local_path, "w")
|
||||
@ -59,6 +59,7 @@ local function download_file(repo_path, local_path)
|
||||
f.close()
|
||||
|
||||
print("OK")
|
||||
return true
|
||||
end
|
||||
|
||||
-- keep track of downloaded files
|
||||
@ -80,13 +81,24 @@ end
|
||||
local args = {...}
|
||||
|
||||
if #args == 0 then
|
||||
print("Syncing " .. #storage .. " files.")
|
||||
|
||||
for local_path, repo_path in pairs(storage) do
|
||||
download_file(repo_path, local_path)
|
||||
-- Lua being Lua, of course #storage won't work
|
||||
local count = 0
|
||||
for _ in pairs(storage) do
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
print("Done.")
|
||||
print("Syncing " .. count .. " files.")
|
||||
|
||||
local success_count = 0
|
||||
for local_path, repo_path in pairs(storage) do
|
||||
local success = download_file(repo_path, local_path)
|
||||
if success then
|
||||
success_count = success_count + 1
|
||||
end
|
||||
end
|
||||
|
||||
print("Done. " .. success_count .. " out of " .. count .. "files synced.")
|
||||
|
||||
elseif args[1] == "sync" then
|
||||
local usage = "gitgud sync <repo path> <local path>"
|
||||
@ -137,4 +149,8 @@ elseif args[1] == "run" then
|
||||
printError(err)
|
||||
end
|
||||
|
||||
else
|
||||
print("Unknown command " .. args[1])
|
||||
print("Try \"sync\", \"delete\" or \"run\"")
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user