From fa7dde796190db7b80045e86c924f2dfd943adfa Mon Sep 17 00:00:00 2001 From: lordtet Date: Wed, 13 Aug 2025 00:09:09 -0400 Subject: [PATCH] First version. It's a bit of a hot mess but it'll let me program with my own text editor, and that's what i need rn. --- README.md | 22 +++++++++++++++++++++- ocbuild.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 ocbuild.lua diff --git a/README.md b/README.md index 36c1dfa..4af896a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ # OCWorkflow -Some workflow related items i thought would be helpful for programming with OpenComputers on a Server \ No newline at end of file +Some workflow related items i thought would be helpful for programming with OpenComputers on a Server + + +## Setup +### The Projfile +The syntax here was inspired by `make` (a la autoconf). Simply running `ocbuild` with a Projfile in your directory will go. +As of now, the profile is simple, and looks like so: +`IP_OF_PROJECT_HTTP_SERVER,NAME_OF_PROJECT` + +For example, if I have my project on an http server at 192.168.0.44, and the directory specs are in myproj.proj, it would look like so: +`192.168.0.44,myproj` + +### Steps +- (Optional) make a project file called "Projfile" in your working directory. The format of the Projfile is specified above. +- Set up an http server whever you want to pull your files from. The server portion is directory-agnostic - the specified HTTP server can be a subdirectory of that server, instead of just the root IP. +- Make sure your project directory has a .proj project store. It simply lists the files to pull, seperated by newlines. These can be subdirectories as well. +- See Usage below. +## Usage +Just run it! If you don't want to use a project file, it will accept a server to pull from and a project file to read as arguments 1 and 2, like so: + +`ocbuild IP_OF_PROJECT_HTTP_SERVER PROJNAME` diff --git a/ocbuild.lua b/ocbuild.lua new file mode 100644 index 0000000..7046b9d --- /dev/null +++ b/ocbuild.lua @@ -0,0 +1,48 @@ +local internet = require("internet") +local shell = require("shell") +local arg = {...} +local fs = require("filesystem") +local req = "" + +local srcserv = "" +local srcproj = "" +if arg[1] ~= nil or arg[2] ~=nil then + srcserv = arg[1] + srcproj = arg[2] +elseif fs.exists(shell.getWorkingDirectory() .. "/Projfile") then + print("pulling from Projfile...") + projfile = shell.getWorkingDirectory() .. "/Projfile" + file = fs.open(projfile,"r") + if file == nil then + print("Need a project file or supplied project info!") + return + end + srcuncut = file:read(256) + + local cut = string.find(srcuncut, ",") + srcserv = string.sub(srcuncut, 0, cut - 1) + srcproj = string.sub(srcuncut, cut + 1) + + print(srcserv) + print(srcproj) + + +else + print("No args and no project file - no idea what to do! Abort.") + return +end + +print("Requesting " .. "http://" .. srcserv .."/" .. srcproj .. ".proj") +local handle = internet.request("http://" .. srcserv .. "/" .. srcproj .. ".proj") +files = "" +for chunk in handle do + files = chunk +end + + + +for str in string.gmatch(files, '([^' .. '\n' .. ']+)') do + shell.execute("wget -f http://" .. srcserv .. "/" .. str) +end + +shell.execute("main")