NAME
App::karr::Role::Output - Role providing common output format options
VERSION
version 0.600
DESCRIPTION
Small role that adds the shared --json option for commands with a machine-readable rendering, and provides the JSON printer used throughout the CLI.
--compact used to be declared here beside it and is not: only nine commands render a compact form, while every command with a --json composes this role, so the shared declaration advertised --compact on thirteen commands that ignored it (#254). It lives in App::karr::Role::CompactOutput now, which those nine compose in addition to this role.
print_json
$self->print_json($data);
In a command class that composes this role, encodes $data (a plain hashref or arrayref) via "json_encode" in App::karr::Encoding and prints it to STDOUT followed by a newline, unconditionally -- unlike "print_json_results" below, it does not check $self->json itself, so a caller that wants the --json gate applies it before calling this method.
print_json_results
$self->print_json_results(@results);
Emits a batch of per-item result hashes as JSON when --json is active, and is a no-op otherwise. A single result is rendered as a bare JSON object and multiple results as a JSON array, matching the output convention shared by the move, edit, delete, and archive commands.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/karr/issues.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)