Skip to content
dantleech edited this page Jan 9, 2014 · 1 revision

Updating the output formatting for phpcr-utils

This document aims to suggest a plan for refactoring the output formatting of the various PHPCR Commands.

I propose that we add a "format" option to all outputish commands, with values such as full, short, tabular, tree, etc.

workspace:query

(or SELECT statements in phpcr-shell)

SELECT * FROM "nt:unstructured" AS a LEFT OUTER JOIN "nt:unstructured" AS n ON a.username = b.username WHERE a.username="lsmith";

Short

+----+-------+----------+-------------+
| #  | Score | a        | b           |
+----+-------+----------+-------------+
| 0  | 7     | /lsmith  | /lsmith     |
| 1  | 3     | /lsmith  | /dantleech  |
+----+-------+----------+-------------+

2 rows in set (0.02 sec)

Full

(this is the current output for phpcr-shell:

| Row: #0 Score: 7
| Sel: a Path: /lsmith UID: none
+-----------------+--------+----------+-----------------------------------+
| Name            | Type   | Multiple | Value                             |
+-----------------+--------+----------+-----------------------------------+
| numbers         | Long   | yes      | [0] 3                             |
|                 |        |          | [1] 1                             |
|                 |        |          | [2] 2                             |
| phpcr:class     | String | no       | Doctrine\Tests\Models\CMS\CmsUser |
| username        | String | no       | lsmith                            |
| jcr:primaryType | Name   | no       | nt:unstructured                   |
+-----------------+--------+----------+-----------------------------------+
| Sel: b Path: /lsmith UID: none
+-----------------+--------+----------+-----------------------------------+
| Name            | Type   | Multiple | Value                             |
+-----------------+--------+----------+-----------------------------------+
| numbers         | Long   | yes      | [0] 3                             |
|                 |        |          | [1] 1                             |
|                 |        |          | [2] 2                             |
| phpcr:class     | String | no       | Doctrine\Tests\Models\CMS\CmsUser |
| username        | String | no       | lsmith                            |
| jcr:primaryType | Name   | no       | nt:unstructured                   |
+-----------------+--------+----------+-----------------------------------+

1 rows in set (0.02 sec)

node-type:list

Short

$ php phpcr phpcr:node-type:list

+-----------------+----------------+---------------------+
| Node Type       | Supertypes     | Subtypes            |
+-----------------+----------------+---------------------+
| nt:unstructured | [0] nt:base    | [0] nt:my-node-type |
|                 |                | [1] node-type-x     |
| nt:unstructured | [0] nt:base    | [0] nt:my-node-type |
+-----------------+----------------+---------------------+

Full

Output to include node definitions

node:dump

Tabular (short)

+-----------------+-----------------+--------------------------+
| Path            | Type            | UUID                     |
+-----------------+-----------------+--------------------------+
| [root]          | nt:base         | 1234-1234-1234-1234-1234 |
|   cms           | nt:unstructured | 1234-1234-1234-1234-1234 |
|   | foobar      | nt:unstructured | 1234-1234-1234-1234-1234 |
|   | barfoo      | nt:unstructured | 1234-1234-1234-1234-1234 |
|   smc           | nt:unstructured | none                     |
|     some        | nt:unstructured | 1234-1234-1234-1234-1234 |
|     | here      | nt:unstructured | 1234-1234-1234-1234-1234 |
|     | there     | nt:unstructured | 1234-1234-1234-1234-1234 |
|     thing       | nt:unstructured | none                     |
+-----------------+-----------------+--------------------------+

Tree

As existing, but maybe we can improve the value formatting:

/
  foobar:
    - jcr:primaryType = nt:unstructured
    barfoo:
      - phpcr = foo
      - jcr:primaryType = nt:unstructured
    lsmith:
      - numbers = Array(    [0] => 3    [1] => 1    [2] => 2)
      - phpcr:class = Doctrine\Tests\Models\CMS\CmsUser
      - username = lsmith
      - jcr:primaryType = nt:unstructured

New Command: Show

Reuse the same display logic as "SELECT|workspace:query"

$ php phpcr:node:show /foobar
+-----------------+--------+----------+-----------------------------------+
| Name            | Type   | Multiple | Value                             |
+-----------------+--------+----------+-----------------------------------+
| numbers         | Long   | yes      | [0] 3                             |
|                 |        |          | [1] 1                             |
|                 |        |          | [2] 2                             |
| phpcr:class     | String | no       | Doctrine\Tests\Models\CMS\CmsUser |
| username        | String | no       | lsmith                            |
| jcr:primaryType | Name   | no       | nt:unstructured                   |
+-----------------+--------+----------+-----------------------------------+