Skip to main content

Create directory trees from a tree specification

Project description

mktree

Create directory trees from a simple text specification. Quickly scaffold project structures, create nested directories, and generate files with comments—all from a single tree description.

Installation

git clone <repository-url>
cd mktree
pip install -e .

Quick Start

Just run

mktree

You'll be prompted to enter your tree specification. End with Ctrl+D or an empty line.

Command-Line Options

  • --root-path PATH: Set the root path for the tree (relabels the root)
  • --parent-path PATH: Wrap the tree in a parent directory
  • -y, --yes: Automatically use default path without prompting
  • --indent-size N: Set indentation size (default: 2)
  • --mode MODE: Set file permissions in octal (default: 777)
  • --no-parents: Don't create parent directories
  • --no-exist-ok: Don't ignore existing directories
  • NOTE: If neither --root-path nor --parent-path is specified, mktree will prompt you for where to create the folder, showing a default based on the first root in your tree, unless you specify -y

From Command Line

mktree "my_project/
  src/
    __init__.py
  tests/
    test_main.py"

From File

mktree < tree.txt

Tree Specification Format

The tree specification supports multiple formats. mktree automatically detects the format based on the input:

Format 1: Indentation-Based (Default)

my_project/
  src/
    __init__.py
    main.py              # This comment will be written as a docstring at the top of main.py
  tests/
    __init__.py
    test_main.py         # Unit tests
  README.md              # Project documentation
  setup.py

Format 2: Unicode Box-Drawing Characters

├── my_project/
│   ├── src/
│   │   ├── __init__.py
│   │   └── main.py              # This comment will be written as a docstring at the top of main.py
│   └── tests/
│       ├── __init__.py
│       └── test_main.py         # Unit tests
├── README.md                     # Project documentation
└── setup.py

Format 3: ASCII Box-Drawing Characters

+-- my_project/
|   +-- src/
|   |   +-- __init__.py
|   |   \-- main.py
|   \-- tests/
|       \-- test_main.py
\-- README.md

Format 4: Prefix Markers

+ my_project/
+ src/
  - __init__.py
  - main.py              # Main entry point
+ tests/
  - __init__.py
  - test_main.py         # Unit tests
- README.md              # Project documentation
- setup.py

Format 5: JSON

{
  "my_project/": {
    "src/": {
      "__init__.py": null,
      "main.py": null
    },
    "tests/": {
      "__init__.py": null,
      "test_main.py": null
    },
    "README.md": null,
    "setup.py": null
  }
}

Format 6: Git ls-tree Format

Git tree format (like git ls-tree -r --name-only):

040000 tree my_project/
040000 tree my_project/src/
100644 blob my_project/src/__init__.py
100644 blob my_project/src/main.py
040000 tree my_project/tests/
100644 blob my_project/tests/__init__.py
100644 blob my_project/tests/test_main.py
100644 blob my_project/README.md
100644 blob my_project/setup.py

Note: mktree automatically detects the format based on the input. You can mix formats in different files, but each individual input should use a single format.

This creates:

my_project/
├── src/
│   ├── __init__.py
│   └── main.py
├── tests/
│   ├── __init__.py
│   └── test_main.py
├── README.md
└── setup.py

Examples

Example 1: Simple Project Structure

mktree "project/
  src/
    __init__.py
    app.py
  tests/
    test_app.py
  README.md"

Interactive Mode

Run without arguments to enter interactive mode:

$ mktree
Enter tree specification (end with Ctrl+D or empty line):
my_project/
  src/
    main.py
  tests/
    test_main.py
^D
Make at path: [./my_project] 
Created tree at: ./my_project

Requirements

  • Python 3.8 or higher
  • No external dependencies

License

Unlicense (Public Domain)

Contributing

Contributions welcome! Please feel free to submit issues or pull requests.

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

modularizer_mktree-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

modularizer_mktree-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modularizer_mktree-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for modularizer_mktree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5fac39677d3196cb730c5016036b51d99af02b363303cdefb9d0f79e395d402
MD5 a5d7f5dfdeeec19981d56984d45a63ab
BLAKE2b-256 6aa38301263dafc067774237542a1b2007516f335c71ea6f8bdf8c0b489093f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for modularizer_mktree-0.1.0.tar.gz:

Publisher: publish.yml on modularizer/mktree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for modularizer_mktree-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 971b2c9a33ca0bec2b1c9d78ff84a8a4b32e0876ccfbe943cd54c666a327a1a4
MD5 4016b667a4372e16d38e0ee0baf2df34
BLAKE2b-256 bd950f795b90ac5802020a810e188f958ba09e858c1cc9541e4682d3b3333cf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for modularizer_mktree-0.1.0-py3-none-any.whl:

Publisher: publish.yml on modularizer/mktree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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