https://github.com/phpbench/tabular-cli
CLI for the tabular reporting library
https://github.com/phpbench/tabular-cli
Last synced: 5 months ago
JSON representation
CLI for the tabular reporting library
- Host: GitHub
- URL: https://github.com/phpbench/tabular-cli
- Owner: phpbench
- Created: 2015-08-30T08:28:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-30T14:57:16.000Z (over 10 years ago)
- Last Synced: 2025-01-19T13:15:36.563Z (about 1 year ago)
- Language: PHP
- Size: 141 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Tabular CLI
===========

This is a simple, demonstration, CLI for the PHPBench
[Tabular](https://github.com/phpbench/tabular) library.
Tabular is a library for generating tabular reports from XML files.
## Example usage
Check the examples in the `examples` folder of this repository, usage as
follows:
````bash
$ php bin/tabular report examples/books/books.xml examples/books/report.json
````

## Definition file
The following is the [Tabular](https://github.com/phpbench/tabular) definition
for the report:
````javascript
{
"classes": {
"euro": [
[ "printf", {"format": "€%2d"} ]
]
},
"rows": [
{
"group": "body",
"cells": [
{
"name": "Title",
"expr": "string(./title)"
},
{
"name": "Stock",
"expr": "string(./stock)"
},
{
"name": "Price",
"class": "euro",
"expr": "number(./price)"
},
{
"name": "Author",
"expr": "string(./author)"
},
{
"name": "Stock Value",
"class": "euro",
"expr": "number(./price) * number(./stock)"
}
],
"with_query": ".//book"
},
{
"cells": []
},
{
"group": "footer",
"cells": [
{
"name": "Stock",
"literal": "Sum >>"
},
{
"name": "{{ cell.item }}",
"class": "euro",
"expr": "sum(//group[@name='body']//cell[@name='{{ cell.item }}'])",
"pass": 2,
"with_items": [ "Price", "Stock Value" ]
}
]
}
]
}
````