Skip to content
/ glug Public

Grepping Library Utilizing Gitignore - Text search tool for programmers, inspired by Ack Beyond Grep and Ag Silver Searcher and written in portable C++20

License

Notifications You must be signed in to change notification settings

dkaszews/glug

Repository files navigation

glug

Text search tool for programmers, inspired by Ack Beyond Grep and Ag Silver Searcher and written in portable C++20.

Philosophy

While ack and ag are written in Perl and C with Linux system headers respectively (port to Windows also exists), glug is written in fully portable C++17 instead, and aims to provide C bindings for use in other languages and programs (e.g. Python-based vim plugin). It also strives for high quality of development, targetting 100% test coverage and 100% accurate .gitignore implementation1, all checked with CI workflows blocking any failing code from being committed.

Usage

Currently, the provided binaries are for testing and demonstration purposes, showcasing the .gitignore implementation by recursively listing files in target directory. grep-like in-file search is to be implemented by the next 0.2.0 release.

Similarly to ack and ag, glug implements convenient shorthands for searching just in files related to given programming language. Whereas those two spell it using separate options like ag --cpp or ack --cpp --nohpp, glug instead expands any glob prefixed with unescaped # into a set of globs stored in its database. This allows unambiguous mixing of type tags with regular globs, so the two examples above would be spelled as '#cpp' and '#cpp,-#hpp respectively.

Currently implemented handful of type tags can be seen in glug --help-tags, with aim to expand in the future and allow user to extend it via config files.

Installing

Check releases tab to find latest stable executable for your system. Release binaries have format glug-${version}-${os}-${arch}-${static:-}-${regex:-}

regex is the regular expression provider, choosing alternative may increase your performance depending on your machine and usage:

  1. stl - default <regex>, omitted in filename
  2. pcre2 - popular implementation of Perl regex, usually already present on Linux as a common dependency
  3. re2 - Google's implementation based on finite state machines
  4. hyperscan - Intel's x86-only implementation leveraging SIMD instructions to increase performance

Compiling from source

  1. Install xmake, can be found on most package providers such as pacman, apt, winget
  2. Optionally, use xmake config to set compilation options (need to set them all at once, as each invocation might reset unmentioned options to default):
    • --regex=stl|pcre2|re2|hyperscan
    • --toolchain=gcc|clang|msvc|...
    • --mode=release|releasedbg|debug|coverage
    • --kind=static|shared
  3. Run xmake build -v to compile executable and tests
  4. Optionally, run tests with xmake test -v
    • xmake test -v unit_test/default runs regular gtest-based UT
    • xmake test -v parity_test/default runs integration tests, comparing results of glug with those of git ls-files on popular repositories1
  5. Binaries can be found in build/${os}/${arch}/${mode}, copied to build/latest

Footnotes

  1. Parity tests ensure glug outputs the same files as git ls-files, save for non-file output (symlinks and submodules) and files matching .gitignore rules which have been accidentally committed. 2

About

Grepping Library Utilizing Gitignore - Text search tool for programmers, inspired by Ack Beyond Grep and Ag Silver Searcher and written in portable C++20

Resources

License

Stars

Watchers

Forks

Packages

No packages published