Giter Club home page Giter Club logo

codesearch's Introduction

๐Ÿ”Ž codesearch

Search for patterns and phrases in your git repository code base.

All this tool is is a glorified and sugar-coated egrep. However, the difference it makes in productivity and getting around a code base is surprising.

Installation

$ brew update  # optional
$ brew install agyorev/tools/codesearch

Use Case

Let's take an example where the tools really shines. Say you're trying to find out how some RPC action, called 'editUser' maps from a JavaScript frontend to a Python backend.

You can first search for all of the occurrences of 'editUser' in your js files, like:

$ codesearch -e js -p "'editUser'"

Then you can look up the same string literal, with some context around it, in your Python files, and see where the action is being registered:

$ codesearch -e py -c 1 -p "'editUser'"

Or maybe you want to look up all of the edit* actions. In this case just use a normal regular expression:

$ codesearch -e py -c 1 -p "'edit[^']+'"

Config (optional)

In case you don't want to look through your whole git repository, maybe there are some irrelevant folders (node_modules, for example), or you don't want to look through all file types.

If this sounds like something you'd like, you should create a file called codesearch.yaml and put it in the root of your git repository.

Currently the following properties are allowed:

extensions:  # only match against files with these extensions, unless specifically set with the -e option.
  - ...

include_folders:  # only show matches from the following folders
  - ...

exclude_folders:  # exclude all files from the following folders from the search
  - ...

You can check out the example config file, for reference.

Usage

Run within a git repository folder.

$ codesearch --help
usage: codesearch [-h] [-f FILE_PATH] [-e EXTENSION] [-i] [-c CONTEXT]
                  (-p PATTERN | -v)

optional arguments:
  -h, --help            show this help message and exit
  -f FILE_PATH, --file-path FILE_PATH
                        Filter based on a matching pattern in the file path
                        name.
  -e EXTENSION, --extension EXTENSION
                        Filter based on the extension type of the file.
  -i, --ignore-case     Case insensitive pattern match.
  -c CONTEXT, --context CONTEXT
                        Number of (context) lines to show around the matches.
  -p PATTERN, --pattern PATTERN
                        The text pattern to find in the code. Regex enabled.
  -v, --version         Display the active version of the tool.

codesearch's People

Contributors

agyorev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.