--format (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

Some values for the option --format that seem to be generally available:

  • body
  • count
  • csv
  • envelope
  • headers
  • ids
  • json
  • table (default)
  • yaml

Not available: tsv

body

Outputs data as an object (I think that's this formatting).

Example:

{"sku":"ca-07-123","price":"12.95","regular_price":"22.95"}{"sku":"ca-07-456","price":"22.95","regular_price":"22.95"}

envelope

Wraps the command’s output in an object, usually with metadata like success status and data. Seems to add more formatting than body

  • Usage: --format=envelope
  • Output structure:
{
  "success": true,
  "data": { ... }
}
  • Best for: When you want additional metadata around the output, especially useful for error handling in scripts.

headers

Outputs only the headers of a table, which represent the column names of the data set.

  • Usage: --format=headers
  • Output Example: For a list command, this might output: ID Name Status
  • Best for: Quickly identifying data structure or available fields without viewing the entire dataset.