10.4. Displaying Pretty-Print Output

The JBoss ON CLI has a special class that formats JBoss ON information into table-style output. This class (TabularWriter) is implicit for all CLI commands, so almost all output is properly formatted automatically. This class is also available as an implicit variable called pretty, which is useful when writing scripts.
For example:
rhqadmin@localhost:7080$ criteria = ResourceCriteria()
    rhqadmin@localhost:7080$ criteria.addFilterResourceTypeName('service-alpha')
    rhqadmin@localhost:7080$ criteria.addFilterParentResourceName('server-omega-0')
    rhqadmin@localhost:7080$ resources = ResourceManager.findResourcesByCriteria(criteria)
    id    name            version resourceType
    ------------------------------------------------
    11373 service-alpha-8 1.0     service-alpha
    11374 service-alpha-1 1.0     service-alpha
    11375 service-alpha-0 1.0     service-alpha
    11376 service-alpha-4 1.0     service-alpha
    11377 service-alpha-2 1.0     service-alpha
    11378 service-alpha-3 1.0     service-alpha
    11379 service-alpha-5 1.0     service-alpha
    11380 service-alpha-9 1.0     service-alpha
    11381 service-alpha-6 1.0     service-alpha
    11382 service-alpha-7 1.0     service-alpha
    10 rows
pretty formats any object defined in the domain (org.rhq.core.domain) package.
Simply printing the output is much less readable:
rhqadmin@localhost:7080$ println(resources)
    PageList[Resource[id=11373, type=service-alpha, key=service-alpha-8, name=service-alpha-8, version=1.0],
    Resource[id=11374, type=service-alpha, key=service-alpha-1, name=service-alpha-1, version=1.0], 
    .... 8< ....
For a single object, pretty checks for the summary information (@Summary), so that it only displays a subset of information. It then prints the summary information for the single object as a formatted list. For example:
rhqadmin@localhost:7080$ pretty.print(resources.get(0))
    Resource:
    id: 11373
    name: service-alpha-8
    version: 1.0
    resourceType: service-alpha