Convert text directory trees (struct.txt) into real folders and files.
Project description
๐ tree2cmd
Convert text-based directory trees into real folders and files.
๐ Table of Contents
- โจ Overview
- ๐ Quick Start
- ๐ฆ Installation
- ๐ Example Input โ Output
- ๐ง Usage Guide
- ๐ง How It Works
- ๐ Documentation
- ๐งช Running Tests
- ๐ Versioning & Publishing
- ๐ค Contributing
- ๐บ๏ธ Roadmap
- ๐ License
- ๐ค Author
โจ Overview
tree2cmd converts text-based directory trees (ASCII/Unicode) like:
Project/
โโโ src/
โ โโโ main.py
โโโ README.md
into actual folders and files using shell commands:
mkdir -p "Project/"
mkdir -p "Project/src/"
touch "Project/src/main.py"
touch "Project/README.md"
Perfect for:
โ Rapid project scaffolding โ Teaching directory layouts โ DevOps automation โ Reproducible project templates โ Converting documentation examples into real directories
Fully tested across ASCII trees, Unicode trees, emoji trees, and mixed indentation styles.
๐ Quick Start
1. Make struct.txt:
Project/
src/
main.py
README.md
2. Convert to commands:
tree2cmd struct.txt
3. Actually create them:
tree2cmd struct.txt --run
๐ฆ Installation
Stable release:
pip install tree2cmd
Latest development version:
pip install git+https://github.com/ajmanjoma/tree2cmd.git
๐ Example Input โ Output
Input:
๐ฆ App/
backend/
api.py
README.md
Output:
mkdir -p "๐ฆ App/"
mkdir -p "๐ฆ App/backend/"
touch "๐ฆ App/backend/api.py"
touch "๐ฆ App/README.md"
This works for any:
- ASCII tree
- Unicode tree
- Emoji directory
- Mixed indentation
- Minimal struct format
- Multi-root trees
๐ง Usage Guide
Dry run (recommended):
tree2cmd struct.txt
Execute commands:
tree2cmd struct.txt --run
Save script:
tree2cmd struct.txt --save setup.sh
Use standard input:
cat struct.txt | tree2cmd --stdin
Show tree instead of commands:
tree2cmd struct.txt --tree
Disable logs:
tree2cmd struct.txt --no-verbose
๐ง How It Works
tree2cmd uses a 3-stage pipeline:
1๏ธโฃ Parsing
Handles:
- ASCII trees (
|-,+--, etc.) - Unicode trees (
โโโ,โ,โโโ) - Mixed whitespaces and unexpected characters
- Emojis and non-ASCII folder names
- Multi-root directories
- Deep nesting
Uses indentation and tree symbols to infer hierarchy.
2๏ธโฃ Classification
Folder detection rules:
- Ends with
/โ folder - Contains
.โ file - Next line is more indented โ folder
- Otherwise โ file
3๏ธโฃ Command Generation
Folders โ mkdir -p
Files โ touch
All paths:
- Are normalized
- Are quoted
- Escape shell-sensitive characters
๐ Documentation
| Topic | File |
|---|---|
| Usage Guide | docs/usage.md |
| CLI Options | docs/cli.md |
| Parser Details | docs/parser.md |
| API Reference | docs/api.md |
| FAQ | docs/faq.md |
| Contributing | docs/contributing.md |
| Changelog | docs/changelog.md |
๐งช Running Tests
Run all tests:
python -m unittest discover -s tests -p "test*.py" -v
With Makefile:
make test
Coverage: 100% (parser + CLI)
๐ Versioning & Publishing
1. Bump version automatically:
make version patch
# or minor / major
2. Build:
python -m build
3. Upload to PyPI:
twine upload dist/*
4. GitHub Actions (automatic):
- On tag push โ build + test + publish
- On PR โ run tests
Workflow located at:
.github/workflows/python-publish.yml
๐ค Contributing
All contributions are welcome!
- Fork repo
- Create a branch
- Add tests for new features
- Run tests
- Open PR
See full guide:
๐ docs/contributing.md
๐บ๏ธ Roadmap
- Windows PowerShell support
- JSON/YAML โ tree converter
- VSCode extension
- GUI visualizer
- Template engine (copy boilerplate files)
๐ License
MIT License โ free for personal & commercial use.
๐ค Author
Antony Joseph Mathew ๐ง antonyjosephmathew1@gmail.com ๐ GitHub: https://github.com/ajmanjoma/tree2cmd
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree2cmd-0.4.3.tar.gz.
File metadata
- Download URL: tree2cmd-0.4.3.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d8fad7936c129e6b44d093abf28b28b57cd34e865120bc00f8c3dcf480bfad4
|
|
| MD5 |
312f11c750ce8eee92c5a77ef6a33698
|
|
| BLAKE2b-256 |
ab2171538f597b5ad6b11a1656fa047b8ed9dd5d0f906507c802d4f24d47d779
|
Provenance
The following attestation bundles were made for tree2cmd-0.4.3.tar.gz:
Publisher:
publish.yml on ajmanjoma/tree2cmd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree2cmd-0.4.3.tar.gz -
Subject digest:
1d8fad7936c129e6b44d093abf28b28b57cd34e865120bc00f8c3dcf480bfad4 - Sigstore transparency entry: 704882827
- Sigstore integration time:
-
Permalink:
ajmanjoma/tree2cmd@5bd33ca0134ee90ba41352ef86e225aeabb98aff -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/ajmanjoma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bd33ca0134ee90ba41352ef86e225aeabb98aff -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree2cmd-0.4.3-py3-none-any.whl.
File metadata
- Download URL: tree2cmd-0.4.3-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33976133c0a6f83cbbc0725cc5d0fb65228ed4f0dcf5129c3f77ef98f633202d
|
|
| MD5 |
0432c7e91d8ac05a9aebc50368221f0a
|
|
| BLAKE2b-256 |
8095350ef52c31f42cea11856f735cc034feb20f5e3f6a4f49b14cb8df2b7920
|
Provenance
The following attestation bundles were made for tree2cmd-0.4.3-py3-none-any.whl:
Publisher:
publish.yml on ajmanjoma/tree2cmd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree2cmd-0.4.3-py3-none-any.whl -
Subject digest:
33976133c0a6f83cbbc0725cc5d0fb65228ed4f0dcf5129c3f77ef98f633202d - Sigstore transparency entry: 704882838
- Sigstore integration time:
-
Permalink:
ajmanjoma/tree2cmd@5bd33ca0134ee90ba41352ef86e225aeabb98aff -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/ajmanjoma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5bd33ca0134ee90ba41352ef86e225aeabb98aff -
Trigger Event:
push
-
Statement type: