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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for DirPrint-0.2.4.tar.gz
Algorithm Hash digest
SHA256 ef6b39f0f22e4fc9cb5b02ef23d02a87714b1c6d0e600763c7658176774ed3b9
MD5 758ec78eb8926ce3726d085dd1140835
BLAKE2b-256 4c304f9c97925a4a40b611d3f9ff2a75e9031fcf87dc5d94877df6b064dd1fc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: DirPrint-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for DirPrint-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a94e72dc3148d063f04153580235e162e3089554a8e9ef53a7a63553e4f3b3c0
MD5 4ed2c69f0e26443214d8560eb93f27e3
BLAKE2b-256 2d87b6734747524ed933d7ac2994f7d1b941fb97614e1d164d8f4c9c1c102dfa

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