此内容没有您所选择的语言版本。

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
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat