grepr: Recursive grep

Description Usage Arguments Details Value Examples

View source: R/grep_remote.R

Description

Recursive call to grep in R

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
grepr(
  pattern,
  path,
  recursive = FALSE,
  ...,
  whole_word = FALSE,
  padding = 1,
  use_crayon = TRUE,
  marker = interactive()
)

Arguments

pattern

character, string containing a regular expression

path

character, path to search, see details

recursive

boolean, Should the listing recurse into directories? passed to list.files, Default: FALSE

...

arguments passed to grep

whole_word

boolean, if TRUE then the pattern will be wrapped with \bpattern\b internally, Default: FALSE

padding

integer, number of rows to return in addition to the query line, Default: 5

use_crayon

boolean, use crayon colors in console output, Default: TRUE

marker

boolean, use rstudioapi marker, Default: interactive()

Details

if path is a character then the pattern is checked against a location on the local machine, if path is a list with arguments containing params for ls_remote then the pattern is checked on the specified remote repository (repository must be public). In this case of the recursive parameter takes over-rides over the list parameter.

Value

grepr(value = FALSE) returns a vector of the indices of the elements of x that yielded a match (or not, for invert = TRUE. This will be an integer vector unless the input is a long vector, when it will be a double vector. grepr(value = TRUE) returns a character vector containing the selected elements of x (after coercion, preserving names but no other attributes).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
grepr(pattern = 'gsub',path = '.',value=TRUE,recursive = TRUE)
thisrepo='metrumresearchgroup/vcs'

remotepath=list(path=thisrepo,subdir='R',vcs='github')
grepr(pattern = 'importFrom',path = remotepath)
grepr(pattern = 'importFrom',path = remotepath,value=TRUE)
grepr(pattern = 'importFrom',path = remotepath,value=TRUE,padding=3)
grepr(pattern = 'tags$script',
      path = list(path = 'timelyportfolio/vueR',subdir='R|inst',vcs='github',PAT = Sys.getenv('GITHUB_PAT')),
padding=3,value=TRUE,fixed=TRUE)

metrumresearchgroup/vcs documentation built on July 16, 2020, 8:52 p.m.