File Coverage

/root/.cpan/build/App-nauniq-0.112-0/script/nauniq
Criterion Covered Total %
statement 37 41 90.2
branch 4 6 66.6
condition 0 2 0.0
subroutine 10 12 83.3
pod n/a
total 51 61 83.6


line stmt bran cond sub pod time code
1             #!perl
2              
3 29     29   184496 use 5.010001;
  29         106  
4 29     29   160 use strict;
  29         51  
  29         930  
5 29     29   320 use warnings;
  29         62  
  29         1696  
6              
7 29     29   12798 use App::nauniq;
  29         25058  
  29         1532  
8 29     29   21026 use Getopt::Long;
  29         525168  
  29         300  
9              
10 29         2322869 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
11 29         92 our $DATE = '2025-09-24'; # DATE
12 29         79 our $DIST = 'App-nauniq'; # DIST
13 29         79 our $VERSION = '0.112'; # VERSION
14              
15 29         341 my %Opts = (
16             append => 0,
17             check_chars => -1,
18             forget_pattern => undef,
19             ignore_case => 0,
20             md5 => 0,
21             num_entries => -1,
22             read_output => 0,
23             show_unique => 1,
24             show_repeated => 0,
25             skip_chars => 0,
26             );
27              
28             sub parse_cmdline {
29 29     29   295 Getopt::Long::Configure("gnu_getopt", "no_ignore_case");
30             my $res = GetOptions(
31             'repeated|d' =>
32 6     6   6472 sub { $Opts{show_unique} = 0; $Opts{show_repeated} = 1 },
  6         56  
33             'ignore-case|i' => \$Opts{ignore_case},
34             'num-entries=i' => \$Opts{num_entries},
35             'skip-chars|s=i' => \$Opts{skip_chars},
36             'unique|u' =>
37 6     6   6403 sub { $Opts{show_unique} = 1; $Opts{show_repeated} = 0 },
  6         55  
38             'check-chars|w=i' => \$Opts{check_chars},
39             'a' => sub {
40 1     1   968 $Opts{append} = 1; $Opts{read_output} = 1;
  1         9  
41             },
42             'append' => \$Opts{append},
43             'forget-pattern=s' => sub {
44 2     2   3355 my ($cbobj, $val) = @_;
45 2 50       4 eval { $val = $Opts{ignore_case} ? qr/$val/i : qr/$val/ };
  2         62  
46 2 100       11 if ($@) {
47 1         26 warn "Invalid regex pattern in --forget-pattern: $@\n"; exit 99;
  1         0  
48             }
49 1         13 $Opts{forget_pattern} = $val;
50             },
51             'md5' => \$Opts{md5},
52             'read-output' => \$Opts{read_output},
53             'help|h' => sub {
54 0     0   0 print <
55             Usage:
56             nauniq [OPTIONS]... [INPUT [OUTPUT]]
57             nauniq --help
58             Options:
59             --repeated, -d
60             --ignore-case, -i
61             --num-entries=N, -n
62             --skip-chars=N, -s
63             --unique, -u
64             --check-chars=N, -w
65             --append
66             --read-output
67             -a
68             --md5
69             --forget-pattern=S
70             For more details, see the manpage/documentation.
71             USAGE
72 0         0 exit 0;
73             },
74             'version|v' => sub {
75 0   0 0   0 print "nauniq version ", ($main::VERSION // 'dev'), "\n";
76 0         0 exit 0;
77             },
78 29         2633 );
79 28 50       29016 exit 99 if !$res;
80             }
81              
82             # MAIN
83              
84 29         106 parse_cmdline();
85 28         297 App::nauniq::run(%Opts);
86              
87             1;
88             # ABSTRACT: Non-adjacent uniq
89             # PODNAME: nauniq
90              
91             __END__