Questo contenuto non è disponibile nella lingua selezionata.

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
Copy to Clipboard Toggle word wrap
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< ....
Copy to Clipboard Toggle word wrap
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
Copy to Clipboard Toggle word wrap
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat