#directory #file #concatenate #utility #cli-file #extension #file-extension

app dirscribe

A CLI tool that combines contents of files with specific extensions from a directory

5 releases (3 breaking)

new 0.4.0-alpha.1 Dec 7, 2024
0.3.1 Dec 4, 2024
0.3.0 Dec 4, 2024
0.2.0 Dec 3, 2024
0.1.0 Dec 3, 2024

#204 in Command line utilities

Download history 395/week @ 2024-12-02

395 downloads per month

MIT license

20KB
351 lines

dirscribe

A CLI tool that collects and combines files with specific extensions from a directory into a single output file.

Features

  • Recursive directory traversal
  • Multiple file extensions support
  • Gitignore rules support
  • Path inclusion/exclusion
  • Keyword filtering
  • Clear file separation in output

Installation

cargo install dirscribe

Usage

Basic syntax:

dirscribe <directory_path> <comma_separated_suffixes> [options]

Example:

dirscribe ./src txt,md,rs

Options

  • --use-gitignore: Respect .gitignore rules
  • --exclude-paths: Comma-separated paths to exclude
  • --include-paths: Comma-separated paths to include
  • --or-keywords: Only include files containing at least one of these keywords
  • --and-keywords: Only include files containing all of these keywords
  • --exclude-keywords: Exclude files containing any of these keywords
  • --diff-only: Only process files that have Git changes
  • --start-commit-id: Starting commit ID for Git diff range (optional). If provided alone without end-commit-id, diffs from this commit to the current working directory
  • --end-commit-id: Ending commit ID for Git diff range (optional). Must be used with start-commit-id

Advanced Example

# Example using Git commit range
dirscribe ./src rs,md \
  --diff-only \
  --start-commit-id abc123 \
  --end-commit-id def456

This will only process files that changed between commits abc123 and def456.

Advanced Example with All Options

dirscribe ./src rs,md \
  --use-gitignore \
  --include-paths src \
  --exclude-paths src/core,src/temp \
  --or-keywords "TODO,FIXME" \
  --and-keywords "pub,struct" \
  --exclude-keywords "DEPRECATED,WIP" \
  --diff-only

Output Format

The tool creates dirscribe.txt in the current directory with entries in this format:

File: /path/to/file1.txt
[Contents of file1.txt]

File: /path/to/file2.md
[Contents of file2.md]

License

MIT License

Dependencies

~14–23MB
~380K SLoC