Project

dirfy

0.0
No release in over 3 years
There's a lot of open issues
Create directory/file structures from ASCII/Unicode tree diagrams
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 13.0
>= 0
 Project Readme

Dirfy

Build Status
Gem Version
License
Ruby β‰₯2.7
Issues

Instantly scaffold directory & file structures from any ASCII/Unicode "tree" diagram πŸš€

πŸ“š Table of Contents

  • πŸ“‹ Problem Statement
  • ✨ Features
  • πŸš€ Installation
  • πŸ’‘ Usage
  • πŸ› οΈ Examples
  • 🀝 Contributing
  • πŸš€ Release Process
  • πŸ“ License

πŸ“‹ 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.

  1. Read our CONTRIBUTING.md for setup instructions, code style, and the PR process.

  2. Fork the repo, branch off main, and open a PR.

  3. Run tests locally:

    bundle install
    bundle exec rake
  4. Ensure your code follows our style (via rake lint) and has adequate test coverage.

  5. Celebrate πŸŽ‰ β€” once your PR is merged, add yourself to AUTHORS.md!

Happy scaffolding! πŸš€


πŸš€ Release Process

This project uses a semi-automated release process that balances automation with security. GitHub Actions handles building and testing, while gem publishing is done manually to support 2FA authentication.

Prerequisites

  • Push access to the repository
  • RubyGems account with push access to the dirfy gem
  • 2FA enabled on RubyGems account (recommended for security)

Semi-Automated Release Process

What's automated:

  • βœ… Gem building when you push tags
  • βœ… Running tests before release
  • βœ… GitHub release creation (optional)

What requires manual action:

  • πŸ” Gem publishing to RubyGems (due to 2FA requirements)

Release Steps

  1. Update version and run tests

    # Edit lib/dirfy/version.rb to bump version
    vim lib/dirfy/version.rb
    bundle install  # updates Gemfile.lock
    bundle exec rake  # run tests
  2. Commit and tag

    git add lib/dirfy/version.rb Gemfile.lock
    git commit -m "chore: bump version to vX.Y.Z"
    git tag vX.Y.Z
    git push origin main --follow-tags
  3. Manual gem publishing (with 2FA)

    rake build
    gem push pkg/dirfy-X.Y.Z.gem
    # Complete 2FA authentication in browser
  4. Optional: Create GitHub release

    gh release create vX.Y.Z pkg/dirfy-X.Y.Z.gem \
      --title "vX.Y.Z" \
      --notes "Release notes here"

Using the Release Helper Script

For even easier releases, use the provided script:

./scripts/release.sh X.Y.Z

This script will:

  • Update the version in lib/dirfy/version.rb
  • Run tests to ensure everything works
  • Build the gem locally
  • Commit changes and create/push the tag
  • Prompt you to manually publish with gem push (for 2FA)

Why Semi-Automated?

  • Security: Maintains 2FA protection on your RubyGems account
  • Reliability: Manual gem push ensures you can handle 2FA interactively
  • Automation: CI still handles building, testing, and GitHub releases
  • Simplicity: No need to manage CI-specific RubyGems accounts or tokens

Troubleshooting

  • 2FA Authentication: Follow the WebAuthn flow in your browser or use --otp flag
  • Build failures: CI will automatically build when you push tags - check Actions tab for issues
  • Permission denied: Ensure you have push access to both the repository and RubyGems gem

πŸ“ License

MIT Β© Ahmed Elhady


Built with ❀️ to make AI-generated project scaffolding a breeze.