Text search tool for programmers, inspired by Ack Beyond Grep and Ag Silver Searcher and written in portable C++20.
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.
`glug --help`
Searches paths for lines matching given patterns. Paths that are directories are
recursively enumerated, using any encountered .gitignore files as filter.
Usage: [OPTIONS] [PATTERN] [PATH...]
POSITIONALS:
PATTERN Search for lines matching PATTERN.
PATH Search files in given PATH, defaults to current directory.
OPTIONS:
-e, --regexp PATTERN Search for lines matching PATTERN. Can be used to specify
multiple patterns, or ones starting with a dash.
-E, --no-regexp, --list Excludes: --regexp
Print all files that would be searched.
-f, --filter FILTER Only search in files that match given filter.
HELP:
--help Print this help message and exit
--help-tags Print builtin tag expansions
--version Print glug version
--license Print license of glug and third-party librariesSimilarly 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.
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:
stl- default<regex>, omitted in filenamepcre2- popular implementation of Perl regex, usually already present on Linux as a common dependencyre2- Google's implementation based on finite state machineshyperscan- Intel's x86-only implementation leveraging SIMD instructions to increase performance
- Install
xmake, can be found on most package providers such aspacman,apt,winget - Optionally, use
xmake configto 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
- Run
xmake build -vto compile executable and tests - Optionally, run tests with
xmake test -vxmake test -v unit_test/defaultruns regulargtest-based UTxmake test -v parity_test/defaultruns integration tests, comparing results ofglugwith those ofgit ls-fileson popular repositories1
- Binaries can be found in
build/${os}/${arch}/${mode}, copied tobuild/latest