Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local STORE_URL = "QV6xpc1r";
- local args = { ... };
- local function help()
- print("Usage: pkgmanager <program_name>")
- end
- local function loadStore()
- local pastebin = "https://pastebin.com/raw/";
- local response, error, fail = http.get(pastebin .. STORE_URL);
- if response == nil then
- return nil, error, fail;
- end
- local file = response.readAll();
- response.close();
- print(file);
- local storeTable = textutils.unserialiseJSON(file);
- return storeTable
- end
- local function downloadProgram(programName, store)
- local program = store[programName];
- if not program then
- print("Error: non-existant program '"..programName.."'.");
- print("Valid options are:");
- for programName, _ in pairs(store) do
- print("- " .. programName);
- end
- end
- print("Installing program!");
- end
- local function main()
- if #args == 0 then
- print("Error: No argument supplied. Please specify which program to install.");
- help();
- return;
- end
- local storeTable, error, fail = loadStore();
- if not storeTable then
- print(error);
- return;
- end
- downloadProgram(args[1], storeTable);
- end
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement