Karl Fogel wrote:
> > One idea I had in my command-line notes was a "script" prefix for
> > commands --- it could be a global flag, too --- which adjusts the
> > syntax of the output for reliable parsing by scripts. Colon-separated
> > fields, simpler argument parsing, or whatever folks feel is useful.
>
> If we could achieve auto-parseable default outputs that are also human
> readable, that's even better. Let's try for that way first. CVS
> *almost* manages it in a lot of places -- and the changes that would
> be necessary to make things fully script-friendly are usually ones
> that would make the output more human-friendly too, I think.
I think here we should take a page from RPM (post 1.0 ;-).
When spitting out data from an ``rpm --query'' command:
The general form of an rpm query command is
rpm -q [query-options]
You may specify the format that package information should
be printed in. To do this, you use the [--queryformat|-qf]
option, followed by the format string.
Query formats are modifed versions of the standard
printf(3) formatting. The format is made up of ... and
printf(3) type formatters. As rpm already knows the type
to print, the type specifier must be omitted however, and
replaced by the name of the header tag to be printed,
enclosed by {} characters.
At the risk of causing a ``not another library'' flame fest,
may I suggest yet another library? :-) With the snprintfv
library (which is in the process of being incorporated into
libiberty, BTW), you can register a callback for the format
specifier (as rpm does above). So:
"%-10{ver}..."
could be used to left justify a 10 character field for the version.
So, you just select a very useful one-line format for the default
and give people lots of rope....
Received on Sat Oct 21 14:36:13 2006