A short description
I haven't released anything in a long time, and I haven't been very active on the forums either lately. So I thought I'd share a library that I made a while back, I haven't really tested it that much, but from what I've experienced it seems to be working quite well.

So what does it do? Well for those who've created scripts in Python you may be familiar with ArgsParser, this was my attempt at doing something like that, but I haven't really implemented everything, as it was a long time since I worked on this and can't really remember what I planned on adding.

For those who're interested in how it looks here's some screenshots of the library set up to a test script, basically an echo script, I didn't feel like screenshots were necessary, but I want to give you a basic feel of how this library works
Screenshots


InstallationFirst of all, you need to download the library, the easiest way is to do it in-game using the built-in pastebin program

pastebin get BamnreZ4 ArgsParser

Direct link for those who want to view it: http://pastebin.com/BamnreZ4

When you've downloaded it, it is pretty simple, all you need to do is load the library using dofile( this is the code you put in your program )

local ArgsParser = dofile( "ArgsParser" ) --# Load the library itself
local parser = ArgsParser.init() --# Initialize a new parser object

That's it, you can find the functions for the parser object below
Functionsobject:addArgument( name, alt, help, _type )
  • name - The name of the argument, if you add "-" before it, it will become an optional argument, if not it's a positional argument.
  • alt - this is the alternative name the user can supply instead of the regular name( optional )
  • help - This is the information that will be displayed when the "-h" or "–help" argument is used, it's basically a description of what the argument is and does.( optional )
  • _type - This is the type you want the argument to be, so if you want it to be a number it will throw an error if it gets a string.( optional )
object:parse( … )
  • - The arguments to parse, I suggest you combine this with varargs.
Example(s)
Echo

local ArgsParser = dofile( "ArgsParser" )
local parser = ArgsParser.init()

local args = {...}

parser:addArgument( "message", nil, "The message to display" )
parser:addArgument( "--color", "-c", "The color to set the text" )
parser:addArgument( "--test", nil, "Just a test", "number" )

args = parser:parse( args )


if colors[args.color] then
	term.setTextColor( colors[args.color] )
end
print( args.message )

If people find it useful I'll continue updating it and adding stuff, fixing bugs etc. I don't know of any bugs as of right now, but you never know. Feedback is appreciated, good or bad.