NAME
WWW::Bund::CLI::Formatter - Template-based output formatter for bund CLI
VERSION
version 0.001
SYNOPSIS
use WWW::Bund::CLI::Formatter;
my $formatter = WWW::Bund::CLI::Formatter->new(
templates_dir => 'share/templates',
strings_dir => 'share/strings',
lang => 'de',
);
# Format with template
my $output = $formatter->format_output($data, 'autobahn_roads', 'template');
# JSON output
my $json = $formatter->format_output($data, undef, 'json');
# YAML output
my $yaml = $formatter->format_output($data, undef, 'yaml');
DESCRIPTION
Template-based formatter for CLI output. Supports three modes:
template- Use YAML templates fromshare/templates/{lang}/to format as tables, lists, or recordsjson- Pretty-print JSONyaml- YAML output
Template Types
Templates define how data should be displayed:
table - Columnar display with headers, auto-sizing, optional wrapping and grid borders
list - Simple vertical list or multi-column list
record - Key-value pairs (single record)
Template files are YAML with structure:
type: table
extract: path.to.data.array # optional
empty: "No data available." # optional
columns:
- field: id
header: ID
width: 10
- field: name
header: Name
width: 40
wrap: true
See share/templates/ for 497 templates across 7 languages.
templates_dir
Directory containing template subdirectories by language. Required.
Structure: {templates_dir}/{lang}/{endpoint_name}.yml
strings_dir
Directory containing localized string files. Required.
lang
Language code for templates and strings. Defaults to de.
template_override
Override path to custom template file. Optional.
When set, this template is used instead of the default endpoint-based lookup.
strings
WWW::Bund::CLI::Strings instance for localized messages.
format_output
my $output = $formatter->format_output($data, $endpoint_name, $mode);
Format data for output. Returns formatted string.
Arguments:
$data- Data structure to format$endpoint_name- Endpoint name for template lookup (optional for json/yaml)$mode- Output mode: 'template', 'json', or 'yaml' (default: 'template')
For template mode, looks up template file based on endpoint name and language. Falls back to YAML if template not found.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-bund/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.