Permalink
Browse files

Observe result metadata: result_format_options

  • Loading branch information...
1 parent b26f73d commit 7b1775a05ea71db09822e93a26224283019e0632 Steven Haryanto (on PC) committed Dec 25, 2012
Showing with 13 additions and 4 deletions.
  1. +11 −4 lib/Perinci/Result/Format.pm
  2. +2 −0 t/01-basics.t
@@ -18,18 +18,25 @@ my $format_text = sub {
"ERROR $res->[0]: $res->[1]" .
($res->[1] =~ /\n\z/ ? "" : "\n");
}
- my $r = $res->[0] == 200 ? $res->[2] : $res;
+ my ($r, $opts);
+ if ($res->[0] == 200) {
+ $r = $res->[2];
+ $opts = $res->[3]{result_format_options} // {};
+ } else {
+ $r = $res;
+ $opts = {};
+ }
if ($format eq 'text') {
return Data::Format::Pretty::format_pretty(
- $r, {module=>'Console'});
+ $r, {%$opts, module=>'Console'});
}
if ($format eq 'text-simple') {
return Data::Format::Pretty::format_pretty(
- $r, {module=>'SimpleText'});
+ $r, {%$opts, module=>'SimpleText'});
}
if ($format eq 'text-pretty') {
return Data::Format::Pretty::format_pretty(
- $r, {module=>'Text'});
+ $r, {%$opts, module=>'Text'});
}
};
View
@@ -30,5 +30,7 @@ is($Perinci::Result::Format::Formats{json}[1],
'application/json',
'mime type 1');
+# XXX test result metadata: result_format_options
+
done_testing();

0 comments on commit 7b1775a

Please sign in to comment.