Skip to main content

A CLI tool to generate a directory structure mapping.

Project description

Dirmapper

Dirmapper is a CLI tool to generate a directory structure mapping. It provides a visual representation of the directory and file structure, similar to the tree command, with support for .gitignore-like patterns to exclude specific files and directories.

Features

  • Generate a hierarchical view of a directory structure.
  • Support for .mapping-ignore file to exclude files and directories.
  • Optional integration with .gitignore to exclude patterns specified in .gitignore.
  • Support for various output styles and formats.

Installation

Using Homebrew

You can install dirmapper using Homebrew:

brew tap nashdean/dirmap
brew install dirmapper

Using pipx

It is recommended to use pipx to install dirmapper in an isolated environment:

pipx install dirmapper

Using pip

You can also install dirmapper using pip:

pip install dirmapper

Usage

Basic Usage

To generate a directory structure mapping:

dirmap /path/to/root_directory /path/to/output_file

Exclude Patterns with .mapping-ignore

Create a .mapping-ignore file in the root directory and specify the patterns you want to exclude:

.git/
*.tmp
*.log

Then run:

dirmap /path/to/root_directory /path/to/output_file --ignore_file /path/to/.mapping-ignore

NOTE: By default, the CLI ships with a .mapping-ignore file that will ignore the following:

.git/

This file can be overridden by specifying your own .mapping-ignore file (named anything you want) using the flag specified earlier --ignore_file /path/to/.mapping-ignore.

Disable .gitignore Integration

By default, dirmap will also consider patterns in .gitignore. To disable this feature:

dirmap /path/to/root_directory /path/to/output_file --ignore_file /path/to/.mapping-ignore --no_gitignore

Show Version

To display the version of dirmapper:

dirmap --version

or

dirmap -v

Specify Sorting Order

To generate a directory structure with ascending order:

dirmap /path/to/root_directory /path/to/output_file --sort asc

To generate a directory structure with descending order:

dirmap /path/to/root_directory /path/to/output_file --sort desc

Specify Output Style and Format

You can specify the style and format of the output using --style and --format options. Available styles include tree, indentation, flat_list, markdown, html, and json. Available formats include plain, html, and json.

Example: HTML Style with HTML Format

dirmap /path/to/root_directory /path/to/output_file --style html --format html

Running All Styles with Their Respective Formats

mkdir -p ./style_outputs
dirmap . ./style_outputs/indentation_output.txt --sort asc --style indentation
dirmap . ./style_outputs/flat_list_output.txt --sort asc --style flat_list
dirmap . ./style_outputs/html_output.html --sort asc --style html --format html
dirmap . ./style_outputs/json_output.json --sort asc --style json --format json
dirmap . ./style_outputs/markdown_output.md --sort asc --style markdown
dirmap . ./style_outputs/tree_output.txt --sort asc --style tree

Example

Sample Directory Structure

project/
├── .git/
│   └── config
├── .github/
│   └── workflows/
│       └── ci.yml
├── src/
│   ├── main.py
│   ├── utils.py
└── README.md

Sample .mapping-ignore

.git/
.github/

Command

dirmap project output.txt --ignore_file project/.mapping-ignore

Sample Output

project/
├── src/
│   ├── main.py
│   └── utils.py
└── README.md

Development

Running Tests

Tests are written using pytest. To run the tests:

  1. Install the development dependencies:
pip install -e .[dev]
  1. Run the tests:
pytest

Troubleshooting

Homebrew

If you have previously tapped and installed the dirmapper package, here’s how you can uninstall and untap it:

  1. Uninstall the Package:
brew uninstall dirmapper
  1. Untap the Repository:
brew untap nashdean/dirmap

Contributing

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

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Nash Dean

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

dirmapper-1.0.6.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

dirmapper-1.0.6-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file dirmapper-1.0.6.tar.gz.

File metadata

  • Download URL: dirmapper-1.0.6.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for dirmapper-1.0.6.tar.gz
Algorithm Hash digest
SHA256 e50493a40c418f139ef5b8988f05e7663b719e1c1f60bec7a11f3365e21bfcc5
MD5 9c0109cc698f856c2413be9bbaf8dde2
BLAKE2b-256 d939c228f7882e7fbb92f9550438b17deb80364fcaecf70ee17455f1ff9ce08f

See more details on using hashes here.

File details

Details for the file dirmapper-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: dirmapper-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for dirmapper-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 323bae80157ac8b04fcecf25d9034503d6f6804b3add9f4042fd8e836489cf0f
MD5 97b40c23a19a090573fb973a1f029d93
BLAKE2b-256 6bd3dd16906524e3aa246305119b420938432f7d15bb8017d9192e609223a711

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