Skip to main content

A tool to create directory and file structures from text representations like the ones you might get from ChatGPT.

Project description

touch-struct

A tool to create directory and file structures from text representations like the ones you might get from ChatGPT.

Installation

You can install via pip:

pip install touch-struct

Usage

touch-struct can be used both as a command-line tool and as a Python library.

Command Line Usage

The most convenient (but maybe not obvious) way to use touch-struct may be to paste the structure directly into your terminal like this:

  1. Copy the structure you want to create into your clipboard. (Usually from ChatGPT or similar)
  2. In your terminal, go to the directory you want to create the structure in.
  3. Type touch-struct - (the dash is important!) and hit enter.
  4. Paste the structure into the terminal.
  5. Press Ctrl+D (which means "end of file") to finish.
  6. Voila! The structure is created!

There are however a few other ways to use it:

# Create from a file
touch-struct structure.txt

# Create in a specific directory
touch-struct structure.txt --output-dir my-new-project

# Create from stdin (pipe)
cat structure.txt | touch-struct -

Python Library Usage

import touch_struct

# Create from a string
structure = """
project/
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
├── README.md
└── setup.py
"""
touch_struct.from_string(structure)

# Create from a file
touch_struct.from_file("structure.txt")

# Create in a specific directory
touch_struct.from_string(structure, base_path="my-new-project")
touch_struct.from_file("structure.txt", base_path="my-new-project")

Structure Format

The tool accepts a text representation of directory structures using ASCII characters:

  • Use / at the end of a line to indicate directories
  • Use standard ASCII characters (, , , ) to draw the tree structure
  • Indentation and structure characters are used to determine hierarchy

Example structure file:

my-project/
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
└── docs/
    ├── index.md
    └── api.md

You can also create multiple root directories or files:

README.md
LICENSE
frontend/
├── src/
│   └── app.js
└── package.json
backend/
├── src/
│   └── server.py
└── requirements.txt

Tips

  • Files shouldn't have a trailing slash: README.md
  • Directories need a trailing slash: src/
  • Spaces in names are supported: My Project/
  • You can mix files and directories at any level
  • The structure can be as deep as you need
  • Root level can contain multiple files and directories

Contributing

For detailed information about contributing, including how to make releases, please see CONTRIBUTING.md.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

touch_struct-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

touch_struct-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file touch_struct-0.1.0.tar.gz.

File metadata

  • Download URL: touch_struct-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for touch_struct-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a9b2e06e524135acb682a960da83b52c3ef3310e6faab551c4f8498a024e5010
MD5 6fcff67532e82dcda1ccecfc84252d9d
BLAKE2b-256 18d12c193967af8c28ad8ad8216fa61d59f00fd5514b604a8305beeb4a60ed50

See more details on using hashes here.

File details

Details for the file touch_struct-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: touch_struct-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for touch_struct-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50949b62f42687f8ae7e561128337fbea1b1e06d1cf8de302d0ce6e89b5f1679
MD5 af5acaf4d22e6dc71b7d5325fdda1cfe
BLAKE2b-256 43c629c68da3c63742aef81f27db5067cf8ce00bb40e24cc0e8bed9060b0aa16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page