The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Perinci::Result::Format::Lite - Format enveloped result

VERSION

This document describes version 0.284 of Perinci::Result::Format::Lite (from Perl distribution Perinci-Result-Format-Lite), released on 2022-01-21.

SYNOPSIS

DESCRIPTION

This module formats enveloped result structure to "pretty text" if it can do so, e.g. the structure can be represented as a 2-dimensional table. Otherwise, it falls back to JSON or Perl. The table formats supported include CSV, TSV, LTSV, or HTML. More table formats (e.g. Org, Markdown) are supported via Text::Table::Any when you set "FORMAT_PRETTY_TABLE_BACKEND".

This module is a more lightweight version of Perinci::Result::Format but the long-term goal is to reunite the two formatting modules back to a modular/pluggable module.

FUNCTIONS

format($res, $format[ , $is_naked=0, $cleanse=1 ]) => str

ENVIRONMENT

FORMAT_PRETTY_TABLE_BACKEND

Str, optional. If this is set, will render text table using Text::Table::Any (with backend set to the value of this environment variable) instead of the default Text::Table::Sprintf. This is useful if you want to output text table in a different format, for example to generate Org tables (make sure Text::Table::Org backend is already installed):

 % FORMAT_PRETTY_TABLE_BACKEND=Text::Table::Org lcpan rdeps Getopt::Lucid

For convenience, a default is chosen for you under certain condition. When inside Emacs (environment INSIDE_EMACS is set), Text::Table::Org is used as default.

FORMAT_PRETTY_TABLE_COLUMN_ORDERS => array (json)

Set the default of table_column_orders in format_options in result metadata, similar to what's implemented in Perinci::Result::Format and Data::Format::Pretty::Console.

COLOR => bool

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Perinci-Result-Format-Lite.

SOURCE

Source repository is at https://github.com/perlancar/perl-Perinci-Result-Format-Lite.

SEE ALSO

Perinci::Result::Format, a more heavyweight version of this module.

Perinci::CmdLine::Lite uses this module to format enveloped result.

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022, 2021, 2020, 2018, 2017, 2016, 2015 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Result-Format-Lite

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.