App-Greple

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

[![Actions Status](https://github.com/kaz-utashiro/greple/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/kaz-utashiro/greple/actions?workflow=test) [![MetaCPAN Release](https://badge.fury.io/pl/App-Greple.svg)](https://metacp...
# NAME

greple - extensible grep with lexical expression and region control

# VERSION

Version 10.04

# SYNOPSIS

**greple** \[**-M**_module_\] \[ **-options** \] pattern \[ file... \]

    PATTERN
      pattern              'and +must -not ?optional &function'
      -x, --le   pattern   lexical expression (same as bare pattern)
      -e, --and  pattern   pattern match across line boundary
      -r, --must pattern   pattern cannot be compromised
      -t, --may  pattern   pattern may exist
      -v, --not  pattern   pattern not to be matched
      -E, --re   pattern   regular expression
          --fe   pattern   fixed expression
      -f, --file file      file contains search pattern
      --select index       select indexed pattern from -f file
    MATCH
      -i, --ignore-case    ignore case
      -G, --capture-group  match capture groups rather than the whole pattern
      -S, --stretch        stretch the matched area to the enclosing block
      --need=[+-]n         required positive match count
      --allow=[+-]n        acceptable negative match count
      --matchcount=n[,m]   required match count for each block
    STYLE
      -l                   list filename only
      -c                   print count of matched block only
      -n                   print line number
      -b                   print block number
      -H, -h               do or do not display filenames
      -o                   print only the matching part
      --all                print entire data
      -F, --filter         use as a filter (implies --all --need=0 --exit=0)
      -m, --max=n[,m]      max count of blocks to be shown
      -A,-B,-C [n]         after/before/both match context
      --join               remove newline in the matched part
      --joinby=string      replace newline in the matched text with a string
      --nonewline          do not add newline character at the end of block
      --filestyle=style    how filenames are printed (once, separate, line)
      --linestyle=style    how line numbers are printed (separate, line)
      --blockstyle=style   how block numbers are printed (separate, line)
      --separate           set filestyle, linestyle, blockstyle "separate"
      --format LABEL=...   define the format for line number and file name
      --frame-top          top frame line
      --frame-middle       middle frame line
      --frame-bottom       bottom frame line
    FILE
      --glob=glob          glob target files
      --chdir=dir          change directory before search
      --readlist           get filenames from stdin
    COLOR
      --color=when         use terminal colors (auto, always, never)
      --nocolor            same as --color=never
      --colormap=color     R, G, B, C, M, Y, etc.
      --colorsub=...       shortcut for --colormap="sub{...}"
      --colorful           use default multiple colors
      --colorindex=flags   color index method: Ascend/Descend/Block/Random/Unique/Group/GP
      --random             use a random color each time (--colorindex=R)
      --uniqcolor          use a different color for each unique string (--colorindex=U)
      --uniqsub=func       preprocess function to check uniqueness
      --ansicolor=s        ANSI color 16, 256 or 24bit
      --[no]256            same as --ansicolor 256 or 16
      --regioncolor        use different color for inside and outside regions
      --face               enable or disable visual effects
    BLOCK
      -p, --paragraph      enable paragraph mode
      --border=pattern     specify a border pattern
      --block=pattern      specify a block of records
      --blockend=s         block-end mark (Default: "--")
      --join-blocks        join consecutive blocks that are back-to-back
    REGION
      --inside=pattern     select matches inside of pattern
      --outside=pattern    select matches outside of pattern
      --include=pattern    limit matches to the area
      --exclude=pattern    limit matches to outside of the area
      --strict             enable strict mode for --inside/outside --block
    CHARACTER CODE
      --icode=name         input file encoding
      --ocode=name         output file encoding
    FILTER
      --if,--of=filter     input/output filter command
      --pf=filter          post-process filter command
      --noif               disable the default input filter
    RUNTIME FUNCTION
      --begin=func         call a function before starting the search
      --end=func           call a function after completing the search
      --prologue=func      call a function before executing the command
      --epilogue=func      call a function after executing the command
      --postgrep=func      call a function after each grep operation
      --callback=func      callback function for each matched string
    OTHER
      --usage[=expand]     show this help message
      --version            show version
      --exit=n             set the command exit status
      --norc               skip reading startup file
      --man                display the manual page for the command or module
      --show               display the module file contents
      --path               display the path to the  module file
      --error=action       action to take after a read error occurs
      --warn=type          runtime error handling type
      --alert [name=#]     set alert parameters (size/time)
      -d flags             display info (f:file d:dir c:color m:misc s:stat)

# INSTALL

## CPANMINUS

README.md  view on Meta::CPAN


        greple -ho --join '\p{InKatakana}+(\n\p{InKatakana}+)*'

    Space separated word sequence can be processed with `--joinby`
    option.  Next example prints all `for *something*` pattern in pod
    documents within Perl script.

        greple -Mperl --pod -ioe '\bfor \w+' --joinby ' '

- **--\[no\]newline**

    Since **greple** can handle arbitrary blocks other than normal text
    lines, they sometimes do not end with newline character.  Option `-o`
    makes similar situation.  In that case, extra newline is appended at
    the end of block to be shown.  Option `--no-newline` disables this
    behavior.

- **--filestyle**=\[`line`,`once`,`separate`\], **--fs**

    Default style is _line_, and **greple** prints filename at the
    beginning of each line.  Style _once_ prints the filename only once
    at the first time.  Style _separate_ prints filename in the separate
    line before each line or block.

- **--linestyle**=\[`line`,`separate`\], **--ls**

    Default style is _line_, and **greple** prints line numbers at the
    beginning of each line.  Style _separate_ prints line number in the
    separate line before each line or block.

- **--blockstyle**=\[`line`,`separate`\], **--bs**

    Default style is _line_, and **greple** prints block numbers at the
    beginning of each line.  Style _separate_ prints block number in the
    separate line before each line or block.

- **--separate**

    Shortcut for `--filestyle=separate` `--linestyle=separate`
    `--blockstyle=separate`.  This is convenient to use block mode search
    and visiting each location from supporting tool, such as Emacs.

- **--format** **LABEL**=_format_

    Define the format string of line number (LINE), file name (FILE) and
    block number (BLOCK) to be displayed.  Default is:

        --format LINE='%d:'

        --format FILE='%s:'

        --format BLOCK='%s:'

    Format string is passed to `sprintf` function.  Escape sequences
    `\t`, `\n`, `\r`, and `\f` are recognized.

    Next example will show line numbers in five digits with tab space:

        --format LINE='%05d\t'

- **--frame-top**=_string_
- **--frame-middle**=_string_
- **--frame-bottom**=_string_

    Print surrounding frames before and after each block.  `top` frame is
    printed at the beginning, `bottom` frame at the end, `middle` frame
    between blocks.

**Related options:**
**--block**/**-p** (["BLOCKS"](#blocks)),
**--color**/**--colormap** (["COLORS"](#colors))

## FILES

- **--glob**=_pattern_

    Get files matches to specified pattern and use them as a target files.
    Using `--chdir` and `--glob` makes easy to use **greple** for fixed
    common job.

- **--chdir**=_directory_

    Change directory before processing files.  When multiple directories
    are specified in `--chdir` option, by using wildcard form or
    repeating option, `--glob` file expansion will be done for every
    directories.

        greple --chdir '/usr/share/man/man?' --glob '*.[0-9]' ...

- **--readlist**

    Get filenames from standard input.  Read standard input and use each
    line as a filename for searching.  You can feed the output from other
    command like [find(1)](http://man.he.net/man1/find) for **greple** with this option.  Next example
    searches string from files modified within 7 days:

        find . -mtime -7 -print | greple --readlist pattern

    Using **find** module, this can be done like:

        greple -Mfind . -mtime -7 -- pattern

## COLORS

- **--color**=\[`auto`,`always`,`never`\], **--nocolor**

    Use terminal color capability to emphasize the matched text.  Default
    is `auto`: effective when STDOUT is a terminal and option `-o` is
    not given, not otherwise.  Option value `always` and `never` will
    work as expected.

    Option **--nocolor** is alias for **--color**=_never_.

    When color output is disabled, ANSI terminal sequence is not produced,
    but functional colormap, such as `--cm sub{...}`, still works.

- **--colormap**=_spec_, **--cm**=...

    Specify color map.  Because this option is mostly implemented by
    [Getopt::EX::Colormap](https://metacpan.org/pod/Getopt%3A%3AEX%3A%3AColormap) module, consult its document for detail and
    up-to-date specification.

    Color specification is combination of single uppercase character
    representing basic colors, and (usually brighter) alternative colors in
    lowercase:



( run in 0.714 second using v1.01-cache-2.11-cpan-e1769b4cff6 )