Skip to main content

Python package and minimalist CLI tool for visualizing, saving, and navigating directory structures.

Project description


Bonzai: A Minimalist Directory Tree CLI Tool & Python Library

Overview

Bonzai is a command-line interface (CLI) tool and Python library designed for working with directory structures in a clear, compact, and visual way. It allows users to generate directory trees, save them as JSON files, load them from JSON, and compute relative paths between directories. The name "Bonsai" reflects the tool's ability to take something complex, like a filesystem, and represent it in an organized and elegant manner.

Features

  • Visualize Directory Trees: Generate and display the structure of directories with optional details like file permissions and file sizes.

  • Export to JSON: Save the directory tree structure as a JSON file for later use or sharing.

  • Load from JSON: Load a directory tree from a JSON file and visualize it.

  • Python API: Compute the relative path between two directories.

  • Relative Paths: Import Bonzai as a Python library for programmatic directory tree manipulation.

Installation

  1. Clone the repository:
git clone https://github.com/abhi-pixel1/bonsai.git
  1. Install the tool using pip:
pip install .

CLI Usage

The Bonzai CLI includes the following commands:

  1. tree

Generates and displays the directory tree for a given directory.

Syntax:

bonsai tree [DIRECTORY_PATH] [OPTIONS]

Arguments:

  • DIRECTORY_PATH: The directory for which the tree should be generated (required).

Options:

  • -p, --show-permissions: Include file permissions in the tree output.

  • -s, --show-size: Include file sizes in the tree output.

Example:

bonzai tree ./my_directory -p -s
  1. save-tree

Saves the directory tree structure of a given directory to a JSON file.

Syntax:

bonzai save-tree [DIRECTORY_PATH] [OUTPUT_FILE]

Arguments:

  • DIRECTORY_PATH: The directory for which the tree should be saved (required).
  • OUTPUT_FILE: The file where the JSON output should be saved. Must have a .json extension.

Example:

bonzai save-tree ./my_directory tree.json
  1. jtree

Loads a directory tree structure from a JSON file and displays it.

Syntax:

bonzai jtree [JSON_FILE] [OPTIONS]

Arguments:

  • JSON_FILE: Path to the JSON file containing the directory tree structure (required).

Options:

  • -p, --show-permissions: Include file permissions in the tree output.
  • -s,--show-size: Include file sizes in the tree output.

Example:

bonzai jtree tree.json -p -s
  1. relative

Calculates and displays the relative path between two directories.

Syntax:

bonzai relative [DESTINATION_PATH] [BASE_PATH]

Arguments:

  • DESTINATION_PATH: The target directory.
  • BASE_PATH: The starting directory.

Example:

bonzai relative ./my_directory ./another_directory

Python API Usage

Bonsai can also be used as a Python library to generate and visualize directory trees programmatically.

Importing Bonzai

from bonzai import generate_directory_tree, visualize_tree

Generating a Directory Tree

from bonzai import generate_directory_tree

tree = generate_directory_tree("./my_directory")
print(tree)

Visualizing a Directory Tree

from bonzai import visualize_tree

print(visualize_tree(tree, show_permissions=True, show_size=True))

Contributers:

Contributors

License

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

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

bonzai-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

bonzai-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file bonzai-0.1.3.tar.gz.

File metadata

  • Download URL: bonzai-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Windows/11

File hashes

Hashes for bonzai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 37c002326a8d822d1d02f6f909b5dba10be625c6331d3836cb8be3413d67c1cc
MD5 de64b940c89ec0c70953128fcd4ca932
BLAKE2b-256 d7351b21d6fe65d260dd91d45c43646c4b0b3819c67c91ebdca2d53d9c53389c

See more details on using hashes here.

File details

Details for the file bonzai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: bonzai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Windows/11

File hashes

Hashes for bonzai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f5b2d519a81503221f6000343fe72449b36e585fbb82229536aed704c3320b8
MD5 aaa28fe71c1b0ee19c679960fc6d2326
BLAKE2b-256 e9d7bb5cc383c3213aada6ce9fc32099c05785edb232286d367cdae2a810fabf

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