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 dir_print

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

Uploaded Python 3

File details

Details for the file dirprint-0.2.1.tar.gz.

File metadata

  • Download URL: dirprint-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1b72e088080ec89517d5e77847c42b2dd6dddfb682a32e8996cf12b1182ac9b0
MD5 46e7c9344a163df5fc6b974dbab68724
BLAKE2b-256 e4f80e16951987a2b292fce189adb2ce048826b381f90360f9ae7ee0f2bd7b38

See more details on using hashes here.

File details

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

File metadata

  • Download URL: DirPrint-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 209d297bb803934a601a6b74363d6a7732e5174bc4ffb76fcdf9dfea9c18ed31
MD5 6b63dd9690f26c2f1d739cac15bd5f6a
BLAKE2b-256 54fa3a78bfa5e770e56ec8fae40756fa331318f9a6c8b7e6db07fecdced15b74

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