RFC: generic command line output templating
Frank Kingswood
frank at kingswood-consulting.co.uk
Wed Sep 28 07:07:27 CDT 2011
On 27/09/11 20:47, Matt Mackall wrote:
> A frequent request is to add --template support to more commands. Here's
> my proposal on how to make our output engine do this generically.
>
> First, observe that the basic problem is to go from an internal
> representation to an external representation with a built-in default.
> Also observe that almost all of our output can be viewed as a list of
> elements made up of key/value pairs. For instance, log is a list of
> changesets with hash/author/date/summary values and status is a list of
> state/filename pairs.
Yes, yes, excellent idea.
Many or indeed most values are strings but have wildly differing
interpretations, so they would need either some additional metadata to be
passed or to be wrapped to help choosing the default representation without
having to code the key names each of them in the templater.
Don't forget a pickle output formatter.
Am I wrong or would this make cmdserver trivial?
Frank
P.S. As you know I maintain the perfarce extension for interfacing with p4.
The one feature I like about p4 is that it allows output to be produced in
something that is easy to parse. Curiously, they picked the marshal format as
one of the output formats, but it works well. But for hg parsing output is
much more ad-hoc and cumbersome.
More information about the Mercurial-devel
mailing list