Command line parser/checker

MarcoSalden marcosalden at yahoo.com
Sat May 4 05:07:20 EDT 2002


Hello,

I am developing an application that uses a Tkinter UI for command line
input towards the application. I have separated the UI from the
application logic and I need to parse the commandline input into
commands with options for the application logic (UI and Logic
separated via a so called 'Commander').
I defined a command line syntax as follows:

<command> [<option=value>]* [<option>]*
E.g. valid command: "doitnow par1=3 par2=foo 1500"
Where I have a list of valid commands and options that are valid for
that command. The sequence order of options should not be relevant,
and values can be strings and integers or just strings.

I want to check the validity of:
<command>: is it a valid command in my list of commands?
<option>: is it a valid option, does it fit in the range I set?
<option=value>: is it a valid option and is the value in the range?

Does anyone know of a open source module/example that I can use to
achieve this? I can program it myself in Python, but why re-invent the
wheel? I suppose this is a rather generic problem that may have been
tackled already?

Thanks in advance,

Marco



More information about the Python-list mailing list