DirPrint: Print your directory structure and file contents with ease.
Project description
Directory Print - DirPrint
Simplify Code Sharing with LLMs by Exporting Directory Structure and File Contents
DirPrint is a command-line tool that streamlines sharing your project's directory structure and file contents with LLMs (like ChatGPT, Claude, etc.). By providing comprehensive context about your codebase, DirPrint enhances LLMs' ability to assist you in debugging and development tasks.
Features
- Visual Directory Tree: Get a clear, hierarchical representation of your project's structure.
- File Contents Display: View file contents within the tree, formatted in markdown code blocks.
- File Export: Save the output to a file for easy sharing and reference.
- Flexible Content Management:
- Ignore Mode: Completely hide specified files/directories from the output.
- Omit Mode: Show files/directories in the directory structure but hide their contents for brevity.
- Strict Matching: Enable exact matching for file/directory names by wrapping the pattern in carets (^).
Installation
From source:
git clone https://github.com/zebangeth/DirPrint.git
cd DirPrint
python setup.py install
Via pip:
pip install DirPrint
or
pip install DirPrint==0.2.8
Usage
Basic command structure:
dir_print [options] <directory_path>
Options
--export,-E: Save output to a specified file.--ignore,-I: Patterns to completely hide (e.g.,__pycache__,.git,node_modules).--omit,-O: Patterns to show in the structure but hide their contents.--show-omitted-structure,--sos: Show structure of omitted directories.
Strict Matching with Carets (^)
By default, patterns are matched partially (i.e., a pattern will match any file or directory that contains it). To enable strict (exact) matching, wrap the pattern in carets. This applies to both ignore and omit modes. For example:
-
Partial matching (default):
dir_print MindPlug -I doc .md build
In this case, any file or directory name that contains "build" (such as
build_check.pyorbuild.py) will be ignored. -
Strict matching:
dir_print MindPlug -I doc .md ^build^
With strict matching, only an entry whose name is exactly
buildwill be ignored.
Note: Depending on your shell, you might need to escape carets (^) so that they are passed as part of the argument.
Examples
Suppose you have a project directory structure like this:
my-project/
├── src/
│ ├── main.js
│ ├── utils.js
│ ├── vite-env.d.ts
│ ├── config/
│ │ ├── dev.js
│ │ └── prod.js
│ ├── config.json
│ └── tests/
│ ├── main.test.js
│ └── utils.test.js
└── README.md
-
Basic usage - Print everything:
dir_print src -
Using ignore - Hide files or directories containing "test":
dir_print src -I test
This will ignore any file or directory with "test" in its name.
-
Using omit (partial matching) - Show in the structure but hide contents:
dir_print src -O config
In this case, both the directory
config/and the fileconfig.jsonwill be omitted because the patternconfigmatches any entry containing that substring:src/ ├── main.js ├── utils.js ├── [omitted] config/ ├── [omitted] config.json └── tests/ ├── main.test.js └── utils.test.js [Contents of files shown except for entries matching "config"...] -
Using strict matching with carets - Match only the exact name:
dir_print src -O ^config^
Here, only an entry whose name is exactly
config(such as theconfig/directory) will be omitted. The fileconfig.jsonwill not be omitted because its name does not exactly equalconfig.
Note: You may need to escape carets depending on your shell. -
Showing omitted structure - View the internal structure of omitted items:
dir_print src -O ^config^ --sos
This shows the structure within the
configdirectory, but its file contents remain omitted. -
Combined usage - Multiple patterns and export:
dir_print src -I node_modules -O ^config^ test -E output.txt --sos
In this example:
node_modulesis ignored using partial matching.^config^is strictly omitted (exact match only) so only an entry named exactlyconfigis affected.testis omitted using partial matching.
Notes
-
Partial Matching: By default, a pattern matches if it is a substring of the file or directory name (e.g.,
testmatchestesting.jsortests/). -
Strict Matching: Wrap a pattern in carets (e.g.,
^build^) to enable exact matching. This ensures the pattern only matches when the file or directory name is an exact match. -
Ignore patterns take precedence over omit patterns when they overlap.
-
The
--sosflag only affects directories marked for omission.
License
Distributed under the MIT License. See LICENSE for more information.
Acknowledgments
- Inspired by the simplicity and utility of the
treecommand in Unix-like operating systems. - Built with GitHub Copilot, GPT-4-0125-preview, and Claude 3.5 Sonnet.
About the Author
DirPrint was created by zebang.eth, a developer passionate about making development and debugging processes smoother and more intuitive.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file DirPrint-0.2.6.tar.gz.
File metadata
- Download URL: DirPrint-0.2.6.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
480e6d58366cd6149157f9ac6c58575ccbf607556bcf43a9d28a236d87abcfcc
|
|
| MD5 |
c809188cf63eed13a987afbab444a52d
|
|
| BLAKE2b-256 |
09d687303c352b0b51a6b373f0721c26c350263abbb97f1dcbfe9020b863d15d
|
File details
Details for the file DirPrint-0.2.6-py3-none-any.whl.
File metadata
- Download URL: DirPrint-0.2.6-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32d2e24dea75018318c13b339b8df9f184c59c9a63348e0342c45221bb4769bf
|
|
| MD5 |
3c8b45bc709e9316aa2f477c1c2e2075
|
|
| BLAKE2b-256 |
095cfdc78d78ddd708fed18ca68d55bc062ce3a91a451a833280089d610e8365
|