What's the suggested syntax for lengthy /command argument lists?
Posted by davidbyron on 2009-11-20 05:58
So I have a simple command for adding a bonus which is,
/bonus number path
That's a simple argument list in line with existing /commands and a small piece of custom parsing gets me that. But I want a much more complex function /effect that allows for many more optional variables such as description, namespace, min/max values, duration etc. And possibly repeated fields. Something like,
/effect name=name desc="this is a description with spaces in it" namespace=Inigo value=4 path=_strength value = 4 path=_dexterity
Although we don't have any other complex commands because they have been thought of as stuff typed in by hand mostly, I am assuming this one will mostly be an instruction in a node so I am not worried about its length. It's like a little script parameter list. We could have a standard parser to extract this stuff to a dictionary for any /command using a lot of optional or repeatable params. The first step then would be an agreeable format for the command line. The = notation above which is a bit like a Python function parameter list is closest to the way some /commands have been written. But basically we've not had optional params before and params with spaces just come last so they get whatever's left over.
Also, is there a simple parser to do stuff like this already out there? getopt was close but not really right and of course uses the Linux style -d --file-name filename -fb "foo bar" format.
/bonus number path
That's a simple argument list in line with existing /commands and a small piece of custom parsing gets me that. But I want a much more complex function /effect that allows for many more optional variables such as description, namespace, min/max values, duration etc. And possibly repeated fields. Something like,
/effect name=name desc="this is a description with spaces in it" namespace=Inigo value=4 path=_strength value = 4 path=_dexterity
Although we don't have any other complex commands because they have been thought of as stuff typed in by hand mostly, I am assuming this one will mostly be an instruction in a node so I am not worried about its length. It's like a little script parameter list. We could have a standard parser to extract this stuff to a dictionary for any /command using a lot of optional or repeatable params. The first step then would be an agreeable format for the command line. The = notation above which is a bit like a Python function parameter list is closest to the way some /commands have been written. But basically we've not had optional params before and params with spaces just come last so they get whatever's left over.
Also, is there a simple parser to do stuff like this already out there? getopt was close but not really right and of course uses the Linux style -d --file-name filename -fb "foo bar" format.
Home / Developer API / Tour / Get a Project - Solutions for Bug & Issue Tracking, Collaboration Tools, Subversion Hosting, Git Hosting
Openrpg is powered by Assembla.
1 Comments
By Digitalxero on 2009-11-20 11:07
Might be what you need, but other then that I cannot think of one off the top of my head that properly identifies quoted strings as a single arg
Though any prebuilt parse I can think of would fail with multiple value=X statements and multiple path=BLA statements.
maybe
and modifying the path parsing in general to understand that a :BLA means to set the value of that node to the new value?