Skip to content

Latest commit

 

History

History
84 lines (74 loc) · 2.19 KB

README.md

File metadata and controls

84 lines (74 loc) · 2.19 KB

Tabular CLI

travis

This is a simple, demonstration, CLI for the 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:

$ php bin/tabular report examples/books/books.xml examples/books/report.json

tabular-cli-phpbench

Definition file

The following is the Tabular definition for the report:

{
    "classes": {
        "euro": [
            [ "printf", {"format": "<info>€</info>%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" ]
                }
            ]
        }
    ]
}