wpkg --showformat ...

The --show command accepts a format that can be defined with the --showformat option.

The format is a string that includes references to fields and characters to print out as is.

  • Field Names

Name of a fields in the format string are introduced with a dollar sign ($) and defined between curly brackets ({ and }). For example, the package name is defined as:

${Package}

The name of a field is case insensitive, so any case is permitted. In other words, ${package} and ${PACKAGE} would also work to print out the name of a package.

  • Field Width

When defining a field, you can specify a width by following the name of the field by a colon and a number. If the number is negative, then the text is left aligned. By default, a positive width aligns the field to the right.

For example, the Installed-Size could be assigned a width of 16 characters:

${Installed-Size:16}

And the package name could be aligned to the left and written in 32 characters with:

${Package:-32}

There cannot be spaces between the package name and the field width specification.

Note that the content of the field is not truncated to the width, so if a package name had more than 32 character, the additional characters would leak to the right.

  • Special Characters

When preceding a character with a backslash it is viewed as a special character. The following characters have a controlled effect:

Special Character Output Comment
\\ \ Insert a backslash by itself (\)
\n Ctrl-J Insert a newline character (0x0A)
\r Ctrl-M Insert a carriage return (0x0D)
\t Ctrl-I Insert a tab character (0x09)
\" " Insert a double quote (")

Any other character is not transformed so it appears as is. (i.e. "\b" will appear as "b").

The double quote is there because DOS batches would otherwise have problems printing out double quotes.

  • Other Characters

Any other character is printed out as is. So for example you could write a sentence:

wpkg --showformat 'Package ${package} version ${version} is ${x-status} since ${x-installed-date}' --show boost

Could write something such as:

Package boost version 1.3.48 is Installed since Nov 18, 2012.

This format may also be useful to transform fields from all the installed packages in a CSV file that you can then manage in a tool such as MS-Excel or LibreOffice Calc.