Skip to main content

A script to display directory structure and Python file contents

Project description

Grobl

Grobl is a command-line tool designed to generate and copy a complete code project file tree along with the contents of valid text files. It's particularly useful for sharing code projects in communication platforms.

Features

  • Generate a file tree for a given list of paths.
  • Exclude specific files and directories from the tree display.
  • Print contents of valid text files (source code, markdown, txt, etc.).
  • Exclude specific files from printing their contents while still showing them in the tree.
  • Parse settings from pyproject.toml files in the directory hierarchy.
  • Copy the output to the clipboard for easy sharing.

Installation

Prerequisites

  • Python 3.11 or later.
  • pipx for isolated Python application installations.

Install using pipx

To install grobl, use the following command:

pipx install grobl

If you don't have pipx installed, you can install it using:

python -m pip install --user pipx
python -m pipx ensurepath

Usage

To use grobl, run the following command:

grobl <paths> [--exclude-tree <patterns>] [--exclude-print <patterns>]

Arguments

  • <paths>: List of file paths to include in the tree.
  • --exclude-tree: Patterns to exclude from the tree display.
  • --exclude-print: Patterns to exclude from file printing.

Example

grobl ./snoop/apriquot ./snoop/weasel --exclude-tree "*.md" --exclude-print "*.css"

This command will:

  • Generate the file tree for the specified paths.
  • Exclude files matching *.md from the tree display.
  • Exclude files matching *.css from being printed.
  • Copy the final output to the clipboard.

pyproject.toml Configuration

You can configure grobl using a pyproject.toml file in your directory hierarchy. The settings in this file will affect the directories containing them and override settings from ancestor directories. Example pyproject.toml

[tool.file_tree_printer]
exclude_tree = ["*.jsonl", "*.jsonl.*", "tests/*", "cov.xml", "*.log", "*.tmp"]
exclude_print = ["*.json", "*.html"]

Configuration Details

  • exclude_tree: A list of glob patterns to exclude from the file tree display. Files and directories matching these patterns will not appear in the tree structure.
  • exclude_print: A list of glob patterns to exclude from file printing. Files matching these patterns will appear in the tree structure but their contents will not be printed.

Example Configuration

Consider the following directory structure:

project-root/
│
├── pyproject.toml
├── src/
│   ├── main.py
│   ├── utils.py
│   └── config.json
├── tests/
│   ├── test_main.py
│   └── test_utils.py
└── README.md

With the following pyproject.toml:

[tool.file_tree_printer]
exclude_tree = ["tests/*", "*.json"]
exclude_print = ["*.md"]

Running grobl project-root/ will:

  1. Exclude the tests directory and config.json file from the tree display.
  2. Exclude README.md from being printed.
  3. Copy the output to the clipboard.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue. License

This project is licensed under the MIT License.

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

grobl-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

grobl-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file grobl-0.1.0.tar.gz.

File metadata

  • Download URL: grobl-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for grobl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba3745c2de127b52ba450a6088a86739c1196a640814df9241db066de01c29eb
MD5 8f726a78e2838f5a9b65fbc82c6350d3
BLAKE2b-256 ee460791d0ce6a4a0a1b2be6e884b9e083cdb0b6d6edfec2612c8d4e7d7fd12d

See more details on using hashes here.

File details

Details for the file grobl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: grobl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for grobl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8918d22a51f0135f72df9ec4fad838f00a5ef2852c969b7a3e36be927bf76719
MD5 17cd464d03e5de9e6d3d08b7c3db157a
BLAKE2b-256 1890d7be6d374ab99049ff39d1769e77262cb59dbe11a06b0113ae02d2612cb4

See more details on using hashes here.

Supported by

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