Skip to main content

build

House-of-Cards (hoc)

A command-line tool to create real file structures on your system from tree-like representations. Easily replicate directory and file structures from your favorite articles, tutorials, LLM answers, or even from tree -F outputs from other users! Just copy the tree structure to your clipboard and you're ready to recreate it on your system.

Features

  • Parses tree-like representations of file structures like:
./
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
└── README.md

and creates them in your system.

  • Handles directories with or without trailing slashes.
  • Compatible with the output of the tree -F command.
  • Can Automatically set appropriate permissions for directories and files.

Installation

Install hoc from PyPI using pip:

pip install house-of-cards

or run it using pipx:

pipx run house-of-cards

or even single runs with uvx:

uvx house-of-cards

Usage

hoc can be used directly from the command line. It reads the file structure string from the clipboard or a file and creates the corresponding directory and file structure at the specified base path.

hoc <base_path> [options]
  • <base_path>: The base directory where the structure will be created. (current directory if not provided)
  • [Options]: Optional arguments to customize the behavior of the command.

[!NOTE]
If the dir that was chosen as base for the generated file structure does not exist it will be created.

Options

  • -f, --file FILENAME: File containing the tree structure. If not provided, the clipboard content will be used.
  • -dp, --dir-permissions PERMISSIONS: Octal permissions for created directories (e.g., 755).
  • -fp, --file-permissions PERMISSIONS: Octal permissions for created files (e.g., 644).
  • -h, --help: Show the help message and exit.

Examples

Example 1: Generating a file structure from the clipboard contents

You can generate a directory structure based on the contents of your clipboard. Just copy the tree-like structure from your favorite tutorial, LLM answer, documentation or the output of a:

 `tree -F .`

command and run hoc by just specifying the base path.

hoc /relative/base/path

Try it by copying the following structure to your clipboard:

etc/
├── apache2/
│   ├── apache2.conf
│   ├── envvars
│   ├── magic
│   ├── mods-available/
│   ├── mods-enabled/
│   ├── sites-available/
│   └── sites-enabled/
├── network/
│   ├── if-up.d/
│   ├── if-down.d/
│   └── interfaces
├── passwd
├── shadow
├── group
└── hosts

and running:

hoc ~/hoc_test

or

hoc 

If you want to use the current directory as the base path.

Example 2: Creating a Structure from a File

Create a file named structure.txt with the following content:

./
├── apache2/
│   ├── apache2.conf
│   ├── envvars
│   ├── magic
│   ├── mods-available/
│   ├── mods-enabled/
│   ├── sites-available/
│   └── sites-enabled/
├── network/
│   ├── if-up.d/
│   ├── if-down.d/
│   └── interfaces
├── passwd
├── shadow
├── group
└── hosts

Run hoc to create the structure:

hoc /relative/base/path -f structure.txt

Example 3: Setting Permissions

You can set the permissions for directories and files using the -dp and -fp options. For example, to set the permissions for directories to 755 and for files to 644, run:

hoc /relative/base/path -dp 755 -fp 644

Example 4: Use it to clone file structures to a remote server or share them with other users

You can use hoc to clone file structures to a remote server by copying the structure using:

tree -F /path/to/directory | pbcopy
or
tree -F /path/to/directory | xclip -selection clipboard

and either share the clipboard content with the other user or save it to a file and send it to them. They can then run hoc on their system to create the same structure or run it on the remote server to create the structure there.

License

This project is licensed under the GNU General Public License version 3. See the LICENSE file for details.

Metadata

Release files for house-of-cards 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for house-of-cards 1.0.1
File Size Uploaded
house_of_cards-1.0.1.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for house-of-cards 1.0.1
File Interpreter ABI Platform
house_of_cards-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.5 kB

Release files / house_of_cards-1.0.1.tar.gz

Download URL house_of_cards-1.0.1.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
82145b925201df62353f1c5458ec63d0f5593348219a777a9f4108e7b8eb64a9
BLAKE2b-256 checksum
How to use checksums
31252f0ed3e8e888dc47d8ba21b2271de0abc5b9219af7864571194cc33c106f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / house_of_cards-1.0.1-py3-none-any.whl

Download URL house_of_cards-1.0.1-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20c517901e5a61f3cd550a8f2006a2a092b0ea7680be4aa32ebf0ffff42b71e7
BLAKE2b-256 checksum
How to use checksums
b6de8a0f96eb0b4c6592096f4c7cdc345847f19154efd1767e06d75816e8a404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page