Dirfy
Instantly scaffold directory & file structures from any ASCII/Unicode βtreeβ diagram π
π Problem Statement
Modern AI code generators (ChatGPT, Copilot, etc.) excel at producing code snippetsβbut often describe project layouts as ASCII or Unicode βtreeβ diagrams. Manually translating those diagrams into a real folder/file structure is:
- Time-consuming & error-prone when projects are large or deeply nested
-
Tedious to type out dozens or hundreds of
mkdir -p
/touch
commands - Prone to typos and forgotten directories
Dirfy automates the entire process: feed it any tree diagram (text or file), and it creates the exact structureβno matter how bigβin seconds.
β¨ Features
- Parse ASCII & Unicode tree diagrams
-
Dry-run mode (
-d
,--dry-run
) to preview changes without writing -
Verbose logging (
-v
,--verbose
) for full action reports -
Custom indent support (
-i N
,--indent=N
) for non-standard tree outputs -
Path prefixing (
-p DIR/
,--prefix=DIR/
) to scaffold under any base folder - Live progress bar and clear success/failure summary
- Zero external dependencies (pure Ruby β₯ 2.7)
π Installation
# via RubyGems
gem install dirfy
# or from source
git clone https://github.com/ahmedmelhady7/dirfy.git
cd dirfy
bundle install
rake install
π‘ Usage
From a file
dirfy path/to/tree.txt
Via pipe
cat tree.txt | dirfy
Common Options
Flag | Description |
---|---|
-d , --dry-run
|
Preview actions without creating files/directories |
-v , --verbose
|
Show each create/skip/fail action |
-i N , --indent=N
|
Set spaces per tree level (default: 4 ) |
-p DIR/ , --prefix=
|
Prepend DIR/ to every generated path |
-h , --help
|
Display help and exit |
π οΈ Examples
Given a file myapp_tree.txt
:
my_app/
βββ lib/
β βββ my_app.rb
βββ spec/
β βββ my_app_spec.rb
βββ README.md
Run:
dirfy -d -v myapp_tree.txt
Output (dry-run):
π Detected 4 items to create.
DRY-RUN Dir: my_app/
DRY-RUN Dir: my_app/lib/
DRY-RUN File: my_app/lib/my_app.rb
DRY-RUN Dir: my_app/spec/
DRY-RUN File: my_app/spec/my_app_spec.rb
DRY-RUN File: my_app/README.md
Remove -d
to actually scaffold.
π€ Contributing
We β€οΈ pull-requests, issues, code-reviews, and β most importantly β your ideas to make dirfy even better.
-
Read our CONTRIBUTING.md for setup instructions, code style, and the PR process.
-
Fork the repo, branch off
main
, and open a PR. -
Run tests locally:
bundle install bundle exec rake
-
Ensure your code follows our style (via
rake lint
) and has adequate test coverage. -
Celebrate π β once your PR is merged, add yourself to
AUTHORS.md
!
Happy scaffolding! π
π License
MIT Β© Ahmed Elhady
Built with β€οΈ to make AI-generated project scaffolding a breeze.