Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

NikoPlus/tree-setup-pack

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🌳 Tree Setup – Instant Project Scaffolding from a Tree Diagram

Python Version License: MIT Platform Code style PRs Welcome

Parse a visual tree diagram – create all folders and empty files instantly.
Perfect for scaffolding projects from tree output, documentation mockups, or your own ASCII/Unicode art.


✨ Features

  • 📁 Creates full directory hierarchies – from a simple text tree
  • 📄 Generates empty files (like touch) with parent directories
  • 🧹 Ignores inline comments – anything inside ( ) is stripped
  • 🧠 Smart parsing – handles ├──, └──, , and spaces
  • 🚫 Optional exclusion – skip build dirs like target/ (one line to uncomment)
  • 🧪 Zero dependencies – uses only Python standard library
  • 💻 Cross‑platform – Linux, macOS, Windows (WSL / Git Bash)

🚀 Quick Start

# 1. Get the script
curl -O https://raw.githubusercontent.com/yourname/tree_setup/main/tree_setup.py
chmod +x tree_setup.py

# 2. Pipe your tree directly into it
./tree_setup.py <<'EOF'
my-project/
├── src/
│   ├── main.rs
│   └── lib.rs
├── Cargo.toml
└── README.md
EOF

Result: the exact tree structure appears on your disk, ready to be filled with code.


📥 Usage

./tree_setup.py [tree-file]
Mode Command
From a file ./tree_setup.py project_tree.txt
From stdin (pipe) cat tree.txt | ./tree_setup.py
From heredoc ./tree_setup.py <<'EOF' ... EOF

🌳 Tree Format Examples

The script accepts any tree that uses these characters:

├──   (middle child)
└──   (last child)
│     (vertical line for indentation)
      (4 spaces also work)

Example with comments (everything inside () is ignored)

bedepacko/                 (root directory)
├── bede.sh                (thin wrapper script)
├── bede-engine/           (Rust project)
│   ├── Cargo.toml
│   ├── src/               (source folder)
│   │   ├── main.rs
│   │   ├── downloader.rs
│   │   ├── resolver.rs
│   │   ├── manifest.rs
│   │   └── lockfile.rs
│   └── target/            (build output – optional)

💡 Tip: You can copy-paste the output of the tree command directly – comments are optional but very handy for documentation.


⚙️ Configuration & Customisation

Skip directories (e.g., target/)

Inside tree_setup.py, uncomment this line:

# entries = [(p, d) for p, d in entries if not p.startswith('target')]

Pre‑populate files with boilerplate

Modify the create_from_entries function. For example, to add fn main() {} to every main.rs:

if full.name == "main.rs":
    full.write_text('fn main() {\n    println!("Hello");\n}\n')

🧪 Real‑world Example: Rust Project

Input (rust-tree.txt):

my_crate/
├── Cargo.toml
├── src/
│   ├── main.rs
│   ├── lib.rs
│   └── bin/
│       └── tool.rs
├── tests/
│   └── integration.rs
└── examples/
    └── demo.rs

Command:

./tree_setup.py rust-tree.txt

Output on disk:

my_crate/
├── Cargo.toml
├── src/
│   ├── main.rs
│   ├── lib.rs
│   └── bin/
│       └── tool.rs
├── tests/
│   └── integration.rs
└── examples/
    └── demo.rs

All files are empty (0 bytes) – ready for you to write code.


📌 Important Notes

  • ✅ Existing files are never overwritten (touch uses exist_ok=True).
  • ✅ Trailing slashes (src/) → directory. No trailing slash → file.
  • ✅ The first line (root directory) is also created.
  • ❌ The script does not write any content by default – only empty placeholders.

🛠 Requirements

  • Python 3.6+ (any modern Python)
  • No third‑party packages – pure standard library.

🤝 Contributing

Issues, feature requests, and pull requests are very welcome!
If you need support for ASCII trees (|--, `--) or other edge cases, please open a ticket.


📄 License

MIT – use freely, modify as you like. Attribution appreciated but not required.


🙌 Acknowledgements

Inspired by developers who love visual project planning and hate manual mkdir & touch marathons.


Happy scaffolding! 🌲✨

About

You can pass the tree text via a file, pipe, or heredoc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.