|
diff --git a/README.md b/README.md
|
| 1 |
`crep` is a command-line tool designed for searching code using [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) queries. Unlike traditional `grep`, which operates on text lines, `crep` understands the structure of your code, allowing for more precise semantic searching. |
1 |
`crep` is a command-line tool designed for searching code using |
|
|
2 |
[Tree-sitter](https://tree-sitter.github.io/tree-sitter/) queries. Unlike |
|
|
3 |
traditional `grep`, which operates on text lines, `crep` understands the |
|
|
4 |
structure of your code, allowing for more precise semantic searching. |
| 2 |
|
5 |
|
| 3 |
## Features |
6 |
## Features |
| 4 |
|
7 |
|
| 5 |
- **Semantic Search**: Uses Tree-sitter to parse code into Concrete Syntax Trees (CSTs) and execute queries against them. |
8 |
- **Semantic Search**: Uses Tree-sitter to parse code into Concrete Syntax Trees |
| 6 |
- **Language Support**: Currently supports **C** and **Python**. |
9 |
(CSTs) and execute queries against them. |
| 7 |
- **Multi-threaded**: Utilizes a custom thread pool for efficient scanning of large codebases. |
10 |
- **Broad Language Support**: Supports multiple languages including C, C++, Go, |
| 8 |
- **Detailed Output**: Reports file path, line number, return type, function name, and parameters for each match. |
11 |
Python, PHP, Rust, and JavaScript. |
|
|
12 |
- **Multi-threaded**: Utilizes a custom thread pool for efficient scanning of |
|
|
13 |
large codebases. |
|
|
14 |
- **Structural Matching**: Reports file path, line number, return type, function |
|
|
15 |
name, and parameters for each match. |
|
|
16 |
- **Debug Mode**: Supports detailed logging via the `DEBUG` environment |
|
|
17 |
variable. |
| 9 |
|
18 |
|
| 10 |
## Prerequisites |
19 |
## Prerequisites |
| 11 |
|
20 |
|
| ... |
| 29 |
./crep <search_term> [path] |
38 |
./crep <search_term> [path] |
| 30 |
``` |
39 |
``` |
| 31 |
|
40 |
|
| 32 |
- `<search_term>`: The string to search for within function names. |
41 |
- `<search_term>`: The string to search for within function/method names. |
| 33 |
- `[path]`: Optional. The directory or file to search (defaults to current directory). |
42 |
- `[path]`: Optional. The directory or file to search (defaults to current directory). |
|
|
43 |
|
|
|
44 |
### Environment Variables |
|
|
45 |
|
|
|
46 |
- `DEBUG=1` or `DEBUG=true`: Enable verbose debug logging. |
| 34 |
|
47 |
|
| 35 |
### Examples |
48 |
### Examples |
| 36 |
|
49 |
|
| ... |
| 44 |
./crep parse main.c |
57 |
./crep parse main.c |
| 45 |
``` |
58 |
``` |
| 46 |
|
59 |
|
|
|
60 |
Run with debug logging enabled: |
|
|
61 |
```bash |
|
|
62 |
DEBUG=1 ./crep init . |
|
|
63 |
``` |
|
|
64 |
|
| 47 |
## How It Works |
65 |
## How It Works |
| 48 |
|
66 |
|
| 49 |
`crep` works by: |
67 |
`crep` works by: |
| 50 |
1. Identifying supported files. |
68 |
|
| 51 |
2. Parsing the files using Tree-sitter grammars. |
69 |
1. Identifying supported files based on extension. |
| 52 |
3. Executing a structural query to find function/method definitions. |
70 |
2. Parsing the files using language-specific Tree-sitter grammars. |
|
|
71 |
3. Executing a structural query to find function/method definitions, including |
|
|
72 |
return types and parameters. |
| 53 |
4. Matching the identifier against the provided search term. |
73 |
4. Matching the identifier against the provided search term. |
| 54 |
5. Displaying the results in a format similar to grep but with added semantic context. |
74 |
5. Displaying the results with added semantic context. |
|
|
75 |
|
|
|
76 |
## Supported Languages |
|
|
77 |
|
|
|
78 |
| Language | Extensions | |
|
|
79 |
| ---------- | -------------- | |
|
|
80 |
| C | `.c`, `.h` | |
|
|
81 |
| C++ | `.cpp`, `.hpp` | |
|
|
82 |
| Go | `.go` | |
|
|
83 |
| Python | `.py` | |
|
|
84 |
| PHP | `.php` | |
|
|
85 |
| Rust | `.rs` | |
|
|
86 |
| JavaScript | `.js` | |
| 55 |
|
87 |
|
| 56 |
## Additional resources |
88 |
## Additional resources |
| 57 |
|
89 |
|
| ... |