lib/FP/Repl.pm

filter: Statementstmt 58.8% 20 / 34 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 55.5% 25 / 45 CC 4 SCAR 22.5
CC
4
Cov
53%
repl
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.4
« lib/Chj/IsPerl.pm ↑ Summary lib/FP/Predicates.pm »
1 #
2 # Copyright (c) 2004-2022 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 - read-eval-print loop
13  
14 =head1 SYNOPSIS
15  
16 use FP::Repl;
17 repl;
18  
19 # To change the default place for both the history and settings
20 # files, set this env var to an absolute path to an existing dir:
21 # $ENV{FP_REPL_HOME}= "/foo/bar";
22  
23 # pass parameters (any fields of the FP::Repl::Repl class):
24 repl (skip => 3, # skip 3 caller frames (when the repl call is nested
25 # within something you dont't want the user to see)
26 tty => $fh, # otherwise repl tries to open /dev/tty, or if that fails,
27 # uses readline defaults (which is somewhat broken?)
28 # also, any fields of the FP::Repl::Repl class are possible:
29 maxHistLen => 100, maybe_prompt => "foo>", maybe_package => "Foo::Bar",
30 maybe_historypath => ".foo_history", pager => ["more"]
31 # etc.
32 );
33  
34 =head1 DESCRIPTION
35  
36 For a simple parameterless start of `FP::Repl::Repl`.
37  
38 =head1 SEE ALSO
39  
40 L<FP::Repl::Repl>: the class implementing this
41  
42 =head1 NOTE
43  
44 This is alpha software! Read the status section in the package README
45 or on the L<website|http://functional-perl.org/>.
46  
47 =cut
48  
49 package FP::Repl;
50 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 1 our @EXPORT = qw(repl);
56 1 our @EXPORT_OK = qw();
57 1 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
58  
59 1 ▶use FP::Repl::Repl;
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 0 ▶sub repl {
Subroutine repl: not called CC=4 SCAR=30.0
Pod undocumented
62 0 ▶ @_ % 2 and die "expecting even number of arguments";
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 and die "expecting even number of arguments" 0 0 0
63 0 my %args = @_;
64 0 my $maybe_skip = delete $args{skip};
65 0 my $maybe_tty = delete $args{tty};
66  
67 0 my $r = FP::Repl::Repl->new;
68  
69 0 ▶ if (exists $args{maybe_settingspath}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"maybe_settingspath"}) 0 0 0
70 0 $r->set_maybe_settingspath(delete $args{maybe_settingspath});
71 }
72  
73 0 $r->possibly_restore_settings;
74  
75 0 for (keys %args) {
76 0 my $m = "set_$_";
77 0 $r->$m($args{$_});
78 }
79  
80 #$r->run ($maybe_skip);
81 0 my $m = $r->can("run");
82 0 @_ = ($r, $maybe_skip);
83 0 goto &$m
84 }
85  
86 1 *FP::Repl = \&repl;
87  
88 1 1
« lib/Chj/IsPerl.pm ↑ Summary lib/FP/Predicates.pm »