Skip to main content

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

Installation

From source:

git clone https://github.com/zebangeth/DirPrint.git
cd DirPrint
python setup.py install

Via pip:

pip install DirPrint==0.2.3

Usage

Basic command structure:

dir_print [options] <directory_path>

Options

  • -E, --export : Save output to specified file
  • -I, --ignore : Patterns to completely hide (e.g., __pycache__, .git)
  • -O, --omit : Patterns to show in structure but hide contents
  • --sos, --show-omitted-structure : Show structure of omitted directories

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
│   └── tests/
│       ├── main.test.js
│       └── utils.test.js
└── README.md

To print the structure and content of the src directory while ignoring the vite-env.d.ts file and the views directory, and saving the output to output.txt, run:

dir_print src -E output.txt -I vite views

Note that partial matching is supported. In this case, for vite-env.d.ts, you can simply write vite.

  1. Basic usage - Print everything:
dir_print src
  1. Using ignore - Hide test files:
dir_print src -I test

Output will not show any files/directories containing "test"

  1. Using omit - Show but hide contents:
dir_print src -O config

Output:

src/
├── main.js
├── utils.js
├── [omitted] config/
└── tests/
    ├── main.test.js
    └── utils.test.js

[Contents of files shown except for config directory...]
  1. Showing omitted structure - View internal structure of omitted items:
dir_print src -O config --sos

Output shows config directory's structure but still omits its contents.

  1. Combined usage - Multiple patterns and export:
dir_print src -I node_modules -O "config" "test" -E output.txt --sos

Notes

  • Patterns support partial matching (e.g., 'test' matches 'testing.js', 'tests/')
  • Ignore takes precedence over omit when patterns overlap
  • The --sos flag 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 tree command 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DirPrint-0.2.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

DirPrint-0.2.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file DirPrint-0.2.3.tar.gz.

File metadata

  • Download URL: DirPrint-0.2.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for DirPrint-0.2.3.tar.gz
Algorithm Hash digest
SHA256 b4725a356aa5127455cc95ff33ac52a60d7cfeb0dd13e99db33d81338e6256f6
MD5 9a1cedd5d0beb01fca1667c3e58d77ea
BLAKE2b-256 d1ed2ddca8837c583ad3f826fcb5543d20dd0b8d58de2d5bbeca9547f493dbeb

See more details on using hashes here.

File details

Details for the file DirPrint-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: DirPrint-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for DirPrint-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 edf8af209164c272ca151be732287199b6bcec2f1cf5f0b97700c648d790b490
MD5 c60f9ed06b8a8a85a6c9ea880de50759
BLAKE2b-256 d86eb0a1a58d47cca2fd762cc7e1c3b8379d7cab433c8c5b61b47acd2cc867f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page