Nmap Development mailing list archives

[NSE][RFC] format.lua library


From: Daniel Miller <bonsaiviking () gmail com>
Date: Wed, 15 Aug 2012 13:14:51 -0500

List,

Since David merged the XML NSE output functionality, I am eager to get started converting old scripts to the new format. To support this, I'm proposing the attached library, which I've called "format" for the moment.

The idea is that there should be a collection of standardized ways of formatting output, to make it easy for script authors to take advantage of the structured output and to promote consistency in the Normal output. The functions I've put into the library to start are mostly focused around the __tostring way of formatting output, since the simple "return a table and a string" way doesn't really need any abstraction. Once this is committed, I'll commit a few of the altered scripts that I've already worked on, to make it clear by example how they are to be used.

The biggest question I have for the list is on the naming of the library. I like "format" because it allows English-sounding reading of code: format.as_horizontal(output), for instance. However, there could possibly be name collisions, since "format" is a common verb, and Lua already provides string.format, which may be localized as "format". Other alternatives: formatting, stringify, output, outform. Please comment or suggest alternatives!

Dan

Attachment: format.lua
Description:

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: