Monday, October 5, 2009

Idea of the day: systematic specification of cmdline parameters

You know how now there are fantastic ways to generate documentation from within source code by using special annotations? I'm referring to things like perldoc and javadoc. They probably call it "self-documenting code" or something equally cheesy, but it's really just a simple markup strategy + a convention for what information is considered useful. Well, my idea today is not exactly analogous, but it's close. Why isn't there a way to systematically specify the format, syntax and semantics of commandline parameters to UNIX programs? For instance, for every binary in a software distribution there could be an XML file (following an as of yet undefined schema, whose definition is really the technical challenge here) specifying all the ways in which that binary can be run. A lot of effort has gone into standardizing the format of "flags", the little -single_char or --blah_blah bits preceding arguments in commandlines. Ditto about --help output. In fact, it's now possible to automagically generate man pages from well-written --help output with help2man. Would it really be such a leap to start including XML specifications for commandline inputs? The potential uses for automation are limitless!

1 comments:

  1. Look at the Python optparse amd argparse libraries. Both are aimed at high-level specification of options and might provide you with ideas.

    ReplyDelete