https://github.com/nextjournal/tafuta
Searching git repositories made easy.
https://github.com/nextjournal/tafuta
Last synced: 11 months ago
JSON representation
Searching git repositories made easy.
- Host: GitHub
- URL: https://github.com/nextjournal/tafuta
- Owner: nextjournal
- Created: 2021-04-06T10:37:51.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-28T13:14:03.000Z (over 4 years ago)
- Last Synced: 2025-02-16T15:06:22.081Z (11 months ago)
- Language: Clojure
- Homepage:
- Size: 36.1 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tafuta
**This is pre-alpha quality. Don't use it.**
* Tafuta - _Search_ in Swahili
A small clojure library for searching code, files and directories inside
a git repository. For the the pattern search of files the library shells out to
[ag](https://github.com/ggreer/the_silver_searcher) or
[ripgrep](https://github.com/BurntSushi/ripgrep) and leverages the speed of those tools.
The results are returned as Clojure data.
The API exposes two functions. In the following `directory` should always be the root of
some git repository.
`(search pattern directory)` - where `pattern` is some pattern you want to look for across tracked
git files.
```clj
(require '[nextjournal.tafuta :as tafuta])
(tafuta/search "foo" ".")
=> ({:line-number 26,
:occurences [[22 3]],
:line " :line \" foo bar\",",
:file "test/nextjournal/tafuta_tests.clj"}
{:line-number 30,
:occurences [[22 3] [25 3]],
:line " :line \" foofoo barbar\",",
:file "test/nextjournal/tafuta_tests.clj"}
{:line-number 33,
:occurences [[32 3] [53 3] [56 3]],
:line
" \":yarn.lock\\n1;1 2: foo bar\\n2;1 2,5 12: foofoo barbar\")))))",
:file "test/nextjournal/tafuta_tests.clj"}
{:line-number 12,
:occurences [[16 3]],
:line "(tafuta/search \"foo\" \".\")",
:file "README.md"})
```
`(search-file pattern directory)` - where `pattern` matches the files one is interested in fuzzily.
```clj
(search-file "clj")
=> ({:path "src/nextjournal/tafuta.clj"}
{:path "test/nextjournal/tafuta_tests.clj"})
```
## Requirements
For the library to work you need to have one of [ag](https://github.com/ggreer/the_silver_searcher) or
[ripgrep](https://github.com/BurntSushi/ripgrep) installed.