summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/DataDumper.pm
blob: ad8d68e333e59f74255da20aacbb788cf7dc8a0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main;
use strict;
use warnings;
# ABSTRACT: format results using Data::Dumper

use mop;

use Data::Dumper;

=head1 SYNOPSIS

  ; .replyrc
  [DataDumper]

=head1 DESCRIPTION

This plugin uses L<Data::Dumper> to format results.

=cut

class Reply::Plugin::DataDumper extends Reply::Plugin {
    submethod BUILD {
        $Data::Dumper::Terse = 1;
        $Data::Dumper::Sortkeys = 1;
    }

    method mangle_result (@result) {
        return Dumper(@result == 0 ? () : @result == 1 ? $result[0] : \@result);
    }
}

1;