srctotext
is a CLI tool written in Go that aggregates
source files into a single text file. It's useful for
generating datasets for generative AI applications.
- Recursive directory search
- Filter files by patterns
- Handles non-binary text files
- Outputs to a specified file
$ brew install perarneng/tap/srctotext
Execute the command with required flags:
$ srctotext --path src/ --include "*.go,*.yaml,Makefile,*.md" -o source.txt
The output file will include contents like:
# FILE: src/test.go
<contents of test.go>
# FILE: src/test.yaml
<contents of test.yaml>
- Specified path must be a directory
- At least one matching file must be found
- Binary files are ignored
Option | Short | Description |
---|---|---|
--path |
-p |
Root folder to search. |
--include |
-i |
Patterns to include (comma-separated) |
--output |
-o |
Output file. |
Using Makefile commands:
make run