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.1

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.2.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.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: DirPrint-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 bfb3e149166fd5d120357e902e6cdcee49de63d4fb936ffbd7358847fde8b3a5
MD5 9f8a3c38e606f8fec8bc9b6849fb17e1
BLAKE2b-256 aec27b50c399dd83aebb6dd290f7544045be2fa4b7897ae6d49ba44e8ee2ae4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: DirPrint-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6376af429b1f58c68ad34af29f3a6233f42ce7686ba8606e6d6c8769c54f80
MD5 21d033318ee2ec30e2b87ad0fe2d24d9
BLAKE2b-256 62ba891f6de19bcef263edd0be8c3f97c92f1bf9fb0b03422e83c5fbf1d83991

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