App-BoolFindGrep

 view release on metacpan or  search on metacpan

bin/bfg  view on Meta::CPAN

#!/usr/bin/env perl

use common::sense;
use warnings FATAL => q(all);
use autodie;
use open IN => q(:locale), OUT => q(:locale);
use Getopt::Long qw(:config no_ignore_case auto_version);
use Pod::Find qw(pod_where);
use Pod::Usage;
use App::BoolFindGrep::CLI;

our $VERSION = '0.06'; # VERSION

my %opt;
#<<<
my $result = GetOptions(
    q(--files-from|T=s)       => sub { $opt{ $_[0] } = $_[1] },
    q(--files-delim|d=s)      => sub { $opt{ $_[0] } = $_[1] },
    q(--file-expr|f=s{1,})    => sub { push @{ $opt{ $_[0] } }, $_[1] },
    q(--find-type|t=s)        => sub { $opt{ $_[0] } = $_[1] },
    q(--find-ignore-case|I)   => sub { $opt{ $_[0] } = $_[1] },
    q(--directory|D=s{1,})    => sub { push @{ $opt{ $_[0] } }, $_[1] },
    q(--fixed-strings|F)      => sub { $opt{ $_[0] } = $_[1] },
    q(--match-expr|m=s{1,})   => sub { push @{ $opt{ $_[0] } }, $_[1] },
    q(--ignore-case|i)        => sub { $opt{ $_[0] } = $_[1] },
    q(--line-regexp|x)        => sub { $opt{ $_[0] } = $_[1] },
    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

version 0.06

=head1 DESCRIPTION



( run in 0.453 second using v1.01-cache-2.11-cpan-ceb78f64989 )