Name | creatree JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | A CLI tool and library to create directory trees from tree strings. |
upload_time | 2025-02-03 21:04:03 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License
Copyright (c) 2025 Subhayu Kumar Bala
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
directory
tree
filesystem
cli
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# creatree


A Python package and CLI tool for creating directory structures from a tree-like string.
## Overview
`creatree` is a simple yet powerful tool that allows you to define directory structures using a human-readable text format and then create those structures automatically in your filesystem. This is particularly useful for quickly setting up project templates, scaffolding applications, or sharing directory structures in documentation.
## Motivation
This project was born out of a major pain point I faced repeatedly—manually creating project structures whenever I started a new project. Since I mostly adhere to the same structure unless there’s a specific need to modify it, I wanted a simple and efficient way to automate this process. Unfortunately, I couldn't find any good tools that fit my workflow.
Additionally, I often write proof-of-concept (POC) functionalities in a Jupyter notebook and later ask ChatGPT to break them down into a structured project format, including a tree with comments. `creatree` bridges this gap by allowing me to quickly generate well-organized project directories without unnecessary manual effort.
## Installation
### Using [`uv`](https://docs.astral.sh/uv)
To install `creatree` as a `uv` tool, run:
```bash
uv tool install creatree
```
### Using `pip`
Alternatively, install `creatree` via `pip`:
```bash
pip install creatree
```
## Usage
### As a Python Library
You can use `creatree` programmatically to generate directory structures.
#### Example Usage
```python
from creatree import creatree, tree_to_dict
# Define a directory tree as a string
tree = '''
example_project/ # Project root
├── main.py # Main entry point
├── config.yaml # Configuration file
├── src/ # Source code directory (Not empty)
│ ├── app.py # Application logic
│ └── utils.py # Utility functions
├── empty_directory/ # Empty directory (This will be created as it ends with /)
└── xyz_file # This will be created as a file as it doesn't end with /
'''
# Convert the tree string to a dictionary
tree_dict = tree_to_dict(tree, include_comments=False)
print(tree_dict)
# Create the directory structure in the current directory
# For each file that has a comment, it will be added to the file as a comment (Think of it like a TODO, except it's not explicit)
creatree(tree, where_to_create=".")
```
### As a CLI Tool
#### Create a directory tree from a file
If you have a text file (for example, `tree.txt`) containing the directory structure, you can create it using:
```bash
creatree tree.txt -w .
```
#### Use pipe to create directory trees
You can also define a directory tree inline using pipes:
```bash
echo "root1/
├── a # This comment will not be present in the a directory :(
│ ├── b.py # This comment will be added to b.py as a comment :)
│ └── c.py
├── d/
└── e.py" | creatree -w .
```
#### Generate a directory tree from an existing structure
You can capture an existing directory structure and replicate it elsewhere using `tree` and `creatree`:
```bash
tree /path/to/existing/directory | creatree -w /path/to/new/location
```
## Comparison with Other Tools
While there are other tools available for scaffolding projects, `creatree` offers a unique approach by allowing users to define directory structures in a simple, tree-like string format. This method provides a clear and concise way to visualize and create complex directory hierarchies without the need for extensive configuration files or templates.
## Features
- Convert a tree string to a structured dictionary.
- Generate directory structures automatically.
- Supports both Python API and CLI usage.
- Works with standard input (`stdin`) for flexible scripting.
- Useful for setting up project templates and scaffolding.
- Supports nested directory structures with file placeholders.
- Lightweight and easy to use.
## Future Roadmap
We have exciting plans to enhance `creatree` further:
- **Template Support**: Allow users to define reusable templates for common project structures.
- **Customization Options**: Enable customization of file contents during creation.
- **Integration with Popular Frameworks**: Provide predefined structures for popular frameworks and libraries.
Stay tuned for these updates!
## How to Contribute
We welcome contributions from the community! Here's how you can get involved:
1. **Fork the Repository**: Click on the 'Fork' button at the top right of the repository page to create a copy of the repository on your GitHub account.
2. **Clone the Forked Repository**: On your local machine, clone the forked repository using:
```bash
git clone https://github.com/yourusername/creatree.git
cd creatree
```
3. **Create a New Branch**: Create a new branch for your feature or bug fix:
```bash
git checkout -b feature-name
```
4. **Make Your Changes**: Implement your feature or fix the bug in your branch.
5. **Commit Your Changes**: Commit your changes with a descriptive commit message:
```bash
git commit -m "Description of the feature or fix"
```
6. **Push to GitHub**: Push your changes to your forked repository:
```bash
git push origin feature-name
```
7. **Create a Pull Request**: Go to the original repository and create a pull request from your forked repository. Provide a clear description of your changes and the motivation behind them.
Before contributing, please ensure that your code adheres to the project's coding standards and that all tests pass. If you're adding a new feature, consider including tests to cover the new functionality.
## License
`creatree` is released under the MIT License, allowing free use, modification, and distribution.
Raw data
{
"_id": null,
"home_page": null,
"name": "creatree",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "directory, tree, filesystem, cli",
"author": null,
"author_email": "Subhayu Kumar Bala <balasubhayu99@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5c/ff/1aff6686918704f5c9d95b0179621cabae4842b28ee05e3a01a251049910/creatree-0.1.1.tar.gz",
"platform": null,
"description": "# creatree\r\n\r\n\r\n\r\n\r\nA Python package and CLI tool for creating directory structures from a tree-like string.\r\n\r\n## Overview\r\n\r\n`creatree` is a simple yet powerful tool that allows you to define directory structures using a human-readable text format and then create those structures automatically in your filesystem. This is particularly useful for quickly setting up project templates, scaffolding applications, or sharing directory structures in documentation.\r\n\r\n## Motivation\r\n\r\nThis project was born out of a major pain point I faced repeatedly\u2014manually creating project structures whenever I started a new project. Since I mostly adhere to the same structure unless there\u2019s a specific need to modify it, I wanted a simple and efficient way to automate this process. Unfortunately, I couldn't find any good tools that fit my workflow.\r\n\r\nAdditionally, I often write proof-of-concept (POC) functionalities in a Jupyter notebook and later ask ChatGPT to break them down into a structured project format, including a tree with comments. `creatree` bridges this gap by allowing me to quickly generate well-organized project directories without unnecessary manual effort.\r\n\r\n## Installation\r\n\r\n### Using [`uv`](https://docs.astral.sh/uv)\r\n\r\nTo install `creatree` as a `uv` tool, run:\r\n\r\n```bash\r\nuv tool install creatree\r\n```\r\n\r\n### Using `pip`\r\n\r\nAlternatively, install `creatree` via `pip`:\r\n\r\n```bash\r\npip install creatree\r\n```\r\n\r\n## Usage\r\n\r\n### As a Python Library\r\n\r\nYou can use `creatree` programmatically to generate directory structures.\r\n\r\n#### Example Usage\r\n\r\n```python\r\nfrom creatree import creatree, tree_to_dict\r\n\r\n# Define a directory tree as a string\r\ntree = '''\r\nexample_project/ # Project root\r\n\u251c\u2500\u2500 main.py # Main entry point\r\n\u251c\u2500\u2500 config.yaml # Configuration file\r\n\u251c\u2500\u2500 src/ # Source code directory (Not empty)\r\n\u2502 \u251c\u2500\u2500 app.py # Application logic\r\n\u2502 \u2514\u2500\u2500 utils.py # Utility functions\r\n\u251c\u2500\u2500 empty_directory/ # Empty directory (This will be created as it ends with /)\r\n\u2514\u2500\u2500 xyz_file # This will be created as a file as it doesn't end with /\r\n'''\r\n\r\n# Convert the tree string to a dictionary\r\ntree_dict = tree_to_dict(tree, include_comments=False)\r\nprint(tree_dict)\r\n\r\n# Create the directory structure in the current directory\r\n# For each file that has a comment, it will be added to the file as a comment (Think of it like a TODO, except it's not explicit)\r\ncreatree(tree, where_to_create=\".\")\r\n```\r\n\r\n### As a CLI Tool\r\n\r\n#### Create a directory tree from a file\r\n\r\nIf you have a text file (for example, `tree.txt`) containing the directory structure, you can create it using:\r\n\r\n```bash\r\ncreatree tree.txt -w .\r\n```\r\n\r\n#### Use pipe to create directory trees\r\n\r\nYou can also define a directory tree inline using pipes:\r\n\r\n```bash\r\necho \"root1/\r\n\u251c\u2500\u2500 a # This comment will not be present in the a directory :(\r\n\u2502 \u251c\u2500\u2500 b.py # This comment will be added to b.py as a comment :)\r\n\u2502 \u2514\u2500\u2500 c.py\r\n\u251c\u2500\u2500 d/\r\n\u2514\u2500\u2500 e.py\" | creatree -w .\r\n```\r\n\r\n#### Generate a directory tree from an existing structure\r\n\r\nYou can capture an existing directory structure and replicate it elsewhere using `tree` and `creatree`:\r\n\r\n```bash\r\ntree /path/to/existing/directory | creatree -w /path/to/new/location\r\n```\r\n\r\n## Comparison with Other Tools\r\n\r\nWhile there are other tools available for scaffolding projects, `creatree` offers a unique approach by allowing users to define directory structures in a simple, tree-like string format. This method provides a clear and concise way to visualize and create complex directory hierarchies without the need for extensive configuration files or templates.\r\n\r\n## Features\r\n\r\n- Convert a tree string to a structured dictionary.\r\n- Generate directory structures automatically.\r\n- Supports both Python API and CLI usage.\r\n- Works with standard input (`stdin`) for flexible scripting.\r\n- Useful for setting up project templates and scaffolding.\r\n- Supports nested directory structures with file placeholders.\r\n- Lightweight and easy to use.\r\n\r\n## Future Roadmap\r\n\r\nWe have exciting plans to enhance `creatree` further:\r\n\r\n- **Template Support**: Allow users to define reusable templates for common project structures.\r\n- **Customization Options**: Enable customization of file contents during creation.\r\n- **Integration with Popular Frameworks**: Provide predefined structures for popular frameworks and libraries.\r\n\r\nStay tuned for these updates!\r\n\r\n## How to Contribute\r\n\r\nWe welcome contributions from the community! Here's how you can get involved:\r\n\r\n1. **Fork the Repository**: Click on the 'Fork' button at the top right of the repository page to create a copy of the repository on your GitHub account.\r\n\r\n2. **Clone the Forked Repository**: On your local machine, clone the forked repository using:\r\n\r\n ```bash\r\n git clone https://github.com/yourusername/creatree.git\r\n cd creatree\r\n ```\r\n\r\n3. **Create a New Branch**: Create a new branch for your feature or bug fix:\r\n\r\n ```bash\r\n git checkout -b feature-name\r\n ```\r\n\r\n4. **Make Your Changes**: Implement your feature or fix the bug in your branch.\r\n\r\n5. **Commit Your Changes**: Commit your changes with a descriptive commit message:\r\n\r\n ```bash\r\n git commit -m \"Description of the feature or fix\"\r\n ```\r\n\r\n6. **Push to GitHub**: Push your changes to your forked repository:\r\n\r\n ```bash\r\n git push origin feature-name\r\n ```\r\n\r\n7. **Create a Pull Request**: Go to the original repository and create a pull request from your forked repository. Provide a clear description of your changes and the motivation behind them.\r\n\r\nBefore contributing, please ensure that your code adheres to the project's coding standards and that all tests pass. If you're adding a new feature, consider including tests to cover the new functionality.\r\n\r\n## License\r\n\r\n`creatree` is released under the MIT License, allowing free use, modification, and distribution.\r\n",
"bugtrack_url": null,
"license": "MIT License\r\n \r\n Copyright (c) 2025 Subhayu Kumar Bala\r\n \r\n Permission is hereby granted, free of charge, to any person obtaining a copy\r\n of this software and associated documentation files (the \"Software\"), to deal\r\n in the Software without restriction, including without limitation the rights\r\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n copies of the Software, and to permit persons to whom the Software is\r\n furnished to do so, subject to the following conditions:\r\n \r\n The above copyright notice and this permission notice shall be included in all\r\n copies or substantial portions of the Software.\r\n \r\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n SOFTWARE.\r\n ",
"summary": "A CLI tool and library to create directory trees from tree strings.",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/subhayu99/creatree/issues",
"Homepage": "https://github.com/subhayu99/creatree"
},
"split_keywords": [
"directory",
" tree",
" filesystem",
" cli"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9b78b8607ec4d697741e5d4e810a07a1669ab49522922086aad5b7577a654946",
"md5": "72448d56b5fcde2c9e297288e18c09a1",
"sha256": "9d892fbf2a300d074d80e9aa0016a5946e7c39f5f613aa94a54ab2ed480ea503"
},
"downloads": -1,
"filename": "creatree-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "72448d56b5fcde2c9e297288e18c09a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 11164,
"upload_time": "2025-02-03T21:04:02",
"upload_time_iso_8601": "2025-02-03T21:04:02.131245Z",
"url": "https://files.pythonhosted.org/packages/9b/78/b8607ec4d697741e5d4e810a07a1669ab49522922086aad5b7577a654946/creatree-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5cff1aff6686918704f5c9d95b0179621cabae4842b28ee05e3a01a251049910",
"md5": "1650215f62912c00d4ec40f02bc07bbf",
"sha256": "0040763a6548de7be3d5f993df34fb22b1245ba00f5f227dbdfb0a16066c2168"
},
"downloads": -1,
"filename": "creatree-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "1650215f62912c00d4ec40f02bc07bbf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11986,
"upload_time": "2025-02-03T21:04:03",
"upload_time_iso_8601": "2025-02-03T21:04:03.272327Z",
"url": "https://files.pythonhosted.org/packages/5c/ff/1aff6686918704f5c9d95b0179621cabae4842b28ee05e3a01a251049910/creatree-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-03 21:04:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "subhayu99",
"github_project": "creatree",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "creatree"
}