App-BoolFindGrep

 view release on metacpan or  search on metacpan

bin/bfg  view on Meta::CPAN

    q(--word-regexp|w)        => sub { $opt{ $_[0] } = $_[1] },
    q(--glob-regexp|g)        => sub { $opt{ $_[0] } = $_[1] },
    q(--files-with-matches|l) => sub { $opt{ $_[0] } = $_[1] },
    q(--slash-as-delim|s)     => sub { $opt{ $_[0] } = $_[1] },
    q(usage|help|h)           => sub { pod2usage( q(-verbose) => 1 ) },
    q(man)                    => sub { pod2usage( q(-verbose) => 2 ) },
);
#>>>

if (@ARGV) {
    say qq(Unparsed options: '@ARGV');
    pod2usage( -verbose => 1 );
}

pod2usage( -verbose => 1 ) if !($result) || !(%opt);

my $obj   = App::BoolFindGrep::CLI->new();
my $check = $obj->args_checker(%opt);

exit 1 unless $check;
exit 1 unless $obj->process();

my @result = @{ $obj->result() };

say for @result;

=pod

=encoding utf8

=head1 NAME

bfg - find and grep files using boolean expressions.

=head1 VERSION

lib/App/BoolFindGrep/CLI.pm  view on Meta::CPAN

    if ($EVAL_ERROR) {
        if ($EVAL_ERROR =~    #
            m{\A(?<msg>.*?)
              \sat\s
              (?<module>.*?)
              \sline\s
              (?<line>\d+)\.\s*\z
             }msx
            )
        {
            say STDERR sprintf q(%s: %s), $PROGRAM_NAME,
                $LAST_PAREN_MATCH{msg};
        }
        return;
    } ## end if ($EVAL_ERROR)

    if ( defined $self->args->{match_expr} ) {
        my ( %result, $num_max );
        foreach my $file ( sort @{ $controller->greped_files() } ) {
            next unless exists $controller->grep->content_found->{$file};
            foreach my $number (

lib/App/BoolFindGrep/CLI.pm  view on Meta::CPAN

        if ( defined $msg ) { $self->_msg($msg); return; }
    } ## end foreach ( @{$values} )

    return 1;
} ## end sub _directory_checker

sub _msg {
    my $self = shift;
    my $msg  = shift;

    say STDERR sprintf q(%s: %s), $PROGRAM_NAME, $msg;
    say STDERR sprintf q(Try '%s --help' for more information.),
        $PROGRAM_NAME;

    return 1;
}

no Moo;
__PACKAGE__->meta->make_immutable;

1;

t/app-boolfindgrep-bool.t  view on Meta::CPAN

#/usr/bin/env perl

use common::sense;
use warnings FATAL => q(all);
use English qw[-no_match_vars];
use List::Util qw[shuffle];
use Test::More;

my $class = q(App::BoolFindGrep::Bool);
use_ok($class) || say q(Bail out!);

my $obj = $class->new();

my @test = (
    [ q{a},     [ [ q(OPERAND), q(a), ] ], ],
    [ q{\(a\)}, [ [ q(OPERAND), q(\\(a\\)), ], ], ],
    [   q{(a)},
        [   [ q(PARENTHESIS), q{(}, ],
            [ q(OPERAND),     q(a), ],
            [ q(PARENTHESIS), q{)}, ],

t/app-boolfindgrep-grep.t  view on Meta::CPAN

#/usr/bin/env perl

use common::sense;
use warnings FATAL => q(all);
use English qw[-no_match_vars];
use Test::More;

my $class = q(App::BoolFindGrep::Grep);
use_ok($class) || say q(Bail out!);

my @test = (
    [   q{.*},
        [   { fixed_strings => qr{\.\*} },
            { line_regexp   => qr{\A.*\z} },
            { word_regexp   => qr{\b.*\b} },
            { ignore_case   => qr{.*}i },
            { glob_regexp   => qr{\.[^/]*} },
        ],
    ],

t/app-boolfindgrep.t  view on Meta::CPAN

        }
    }
} ## end foreach my $day (@day)

if ( @tmpfile != @day * @sep * @suffix ) {
    rmdir $tmpdir;
    BAIL_OUT(q(Can't create files to test.));
}

my $class = q(App::BoolFindGrep);
use_ok($class) || say q(Bail out!);

my @test = (
    {   literal => [
            [ q(test_)  => @day * @suffix, ],    #
            [ q(.tmp)   => @day * @sep, ],       #
            [ q(-1970-) => @day * @suffix, ],    #
        ],
    },
    {   glob => [



( run in 0.556 second using v1.01-cache-2.11-cpan-9169edd2b0e )