Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------
- -- fetch (Computer Craft)
- -- This program fetches pastebins based on an internal table
- -- To use run: fetch programname
- ------------------------------------------------------------
- -- Table of <program name, pastebin string> pairs
- local progTable = {
- {"quarry", "HKvSqARi"},
- {"stripmine", "7Q3kjTQB"}
- }
- function main()
- -- Get the target
- if (arg[1] == nil) then
- print("Specify a program")
- return
- end
- -- Check if the target exists in the table
- target = nil
- for i = 1, #progTable do
- if (arg[1] == progTable[i][1]) then
- target = progTable[i][2]
- end
- end
- if (target == nil) then
- print("Target not found.")
- return
- end
- -- the program was found
- name = arg[1] .. ".lua"
- -- remove the current version
- res1 = shell.run("rm", name)
- -- get the new version
- res2 = shell.run("pastebin", "get", target, name)
- if (res1 and res2) then
- print("Fetched " .. name)
- else
- print("Fetch failed")
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement