Posted 10 July 2014 - 09:35 AM
This is my first publicly released program, feel free to give any feedback and criticism.
DropBox is a way for you to use any text editor for programming and debugging when you do not have access to comptuercraft's file system. This program will allow you to type code in ANY program, hit save, then execute the code immediate.
The way it works is by you giving the program a url and filename (technicly any service will do, but the auto synk of dropbox plays a big part) of a dropbox file. The program then generates what I call a “Go” file in the root of your comptuercraft computer.
Go files will update the program from the url source then immediately execute said program. This way, after you do a bit of debugging on your code in, say, Notepad++, all you have to do is save your program, then type “go” on your comptuer, then instantly test your code.
As I said, this can be used with any url, but for it to work best you would need a service that autocratically synks files on your hardrive with that on the service.
Also, please note you will have to share the file publicly, and grab the right url from dropbox. You might also have to edit the url a little bit. The url dropbox gives is
—–PasteBin and Details—–
pastebin: TRjNQrbq
It's command line, so just execute the program to see the arguments.
sourcecode:
changelog:
error handlers for when urls or filenames do not work right
support for directories
figure out a way for for "go" files to pass command line arguments to the program they are executing
v0.5 – first release
Thank you for checking this out :)/>
DropBox is a way for you to use any text editor for programming and debugging when you do not have access to comptuercraft's file system. This program will allow you to type code in ANY program, hit save, then execute the code immediate.
The way it works is by you giving the program a url and filename (technicly any service will do, but the auto synk of dropbox plays a big part) of a dropbox file. The program then generates what I call a “Go” file in the root of your comptuercraft computer.
Go files will update the program from the url source then immediately execute said program. This way, after you do a bit of debugging on your code in, say, Notepad++, all you have to do is save your program, then type “go” on your comptuer, then instantly test your code.
As I said, this can be used with any url, but for it to work best you would need a service that autocratically synks files on your hardrive with that on the service.
Also, please note you will have to share the file publicly, and grab the right url from dropbox. You might also have to edit the url a little bit. The url dropbox gives is
https://www.dropbox.com/s/f7k3L1nk/code.lua
but the url you would need for the direct download the program requires is
https://dl.dropboxusercontent.com/s/f7k3L1nk/code.lua
—–PasteBin and Details—–
pastebin: TRjNQrbq
It's command line, so just execute the program to see the arguments.
sourcecode:
Spoiler
--#{...} counts the ammount of aguments
local commandLine ={...} --allows the program to accept command line aguments in a table
if #{...} == 0 then --a small guide that displays without command line arguments.
print("Welcome to Dropbox Go,")
print("Write code with any editor on http enabled servers")
local programName = fs.getName(shell.getRunningProgram()) --thank you bit for this part
local usage = string.format([[Usage:
%s genGo <url> <input file> [output file]
%s download <url> <output file>
< > arguments are required
[ ] arguments are optional]], programName, programName)
print(usage)
elseif commandLine[1] == "genGo" then --primary usage, generate a file called "go" to allow quick exicution of files saved in dropbox
if #{...} < 3 then --if there are fewer than 3 arguments warn the user and stop the code
print("not enough arguments")
elseif #{...} > 4 then --if there are more than 4 arguments warn the user and stop the program
print("too many arguments")
elseif #{...} == 3 then --if there are 3 arguments, generate the go file
local fileName = "ugg"
local programName = fs.getName(shell.getRunningProgram()) --gets the name of this program for propper generation
local file = fs.open("go", "w") --opens and writes the file "go"
file.writeLine('shell.run("'..programName..'","download","'..tostring(commandLine[2])..'","'..commandLine[3]..'")')
file.writeLine('shell.run("'..commandLine[3]..'")')
file.close()--finish editing the file
else --this will only happen with 5 command line arguments, same as above but lets the user name the "go"file
local programName = fs.getName(shell.getRunningProgram())
local file = fs.open(tostring(commandLine[4]), "w")
file.writeLine('shell.run("'..programName..'","download","'..tostring(commandLine[2])..'","'..commandLine[3]..'")')
file.writeLine('shell.run("'..commandLine[3]..'")')
file.close()
end
elseif commandLine[1] == "download" then --this part downloads files from the web, its primarly used in "go" files to grab files but figured might as well let users know it exists.
if #{...} < 3 then --again, this sectiong is for making sure that there are not too many/few arguments
print("not enough arguments")
elseif #{...} > 3 then
print("too many arguments")
else
local site = http.get(commandLine[2]) --this download a file from the internet to your computercraft computer
local file = io.open(commandLine[3], "w")
file:write(site:readAll())
file:close()
end
else
print("invalid command") --a bad command was used.
end
changelog:
Spoiler
to be added,error handlers for when urls or filenames do not work right
support for directories
figure out a way for for "go" files to pass command line arguments to the program they are executing
v0.5 – first release
Thank you for checking this out :)/>
Edited on 10 July 2014 - 07:39 AM