pypa/pip — pull request #797 by rafaelcaricio (2013-02-09 01:26:47+00:00)
Title: Add option to customize the output format of the "pip list" commad

As suggested in the issue #752 this pull request add a new option to pip list command which enable the possibility to customize the output format. An example of generation of a CSV output would be:

$ echo "Name,Version" && pip list --format "{name},{version}"
Name,Version
git-remote-helpers,0.1.0
wsgiref,0.1.2
mock,1.0.1
nose,1.2.1
ScriptTest,1.2
virtualenv,1.8.4

And a more elaborated example:

$ CONTENT=`pip list --format '{{"name":"{name}","version":"{version}"}},'` && echo "{${CONTENT%,}}"
{{"name":"git-remote-helpers","version":"0.1.0"},
{"name":"wsgiref","version":"0.1.2"},
{"name":"mock","version":"1.0.1"},
{"name":"nose","version":"1.2.1"},
{"name":"ScriptTest","version":"1.2"},
{"name":"virtualenv","version":"1.8.4"}}

Above is an example of generation of json like output using the new format option with a little effort. So, as you can see users can easily create customs outputs which can be much more easily parseable by automated tools.