| 1 | # | ||
| 2 | # Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch | ||
| 3 | # | ||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||
| 7 | # bundled with this file. | ||
| 8 | # | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | FP::Repl::Trap | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | use FP::Repl::Trap; | ||
| 17 | die "fun"; # opens a repl from FP::Repl | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | Dead-simple wrapper around FP::Repl::WithRepl that simply enables trapping | ||
| 22 | globally. | ||
| 23 | |||
| 24 | NOTE: the name is not set in stone yet, also, perhaps it should be | ||
| 25 | *merged* with FP::Repl::WithRepl. | ||
| 26 | |||
| 27 | =head1 SEE ALSO | ||
| 28 | |||
| 29 | L<FP::Repl::WithRepl>, L<FP::Repl::AutoTrap> | ||
| 30 | |||
| 31 | =head1 NOTE | ||
| 32 | |||
| 33 | This is alpha software! Read the status section in the package README | ||
| 34 | or on the L<website|http://functional-perl.org/>. | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | package FP::Repl::Trap; | ||
| 39 | |||
| 40 | use strict; | ||
| 41 | use warnings; | ||
| 42 | use warnings FATAL => 'uninitialized'; | ||
| 43 | |||
| 44 | use FP::Repl::WithRepl; | ||
| 45 | |||
| 46 | if (($ENV{RUN_TESTS} // '') eq '1') { | ||
| 47 | warn "not activating since running in test mode"; | ||
| 48 | } else { | ||
| 49 | push_withrepl(0); | ||
| 50 | } | ||
| 51 | |||
| 52 | 1 |