Skip to main content

A CLI tool to create directory structures from a structure file.

Project description

Maketree CLI

GitHub Repository Latest PyPi version supported Python versions Project licence Black Automated testing results PyPI - Downloads

A Command-line Application to create directory structures from a structure file. It let's you create the most complex directory structures in a blink or two.

Features:

  • Zero dependencies
  • Easy to write structure syntax
  • User friendly.

Installation:

maketree can easily be installed using pip.

pip install maketree

python>=3.8 must be installed on your system.

Basic Usage:

Once maketree is installed, you can run it from any location in your terminal.

>> maketree -h
usage: maketree [OPTIONS]

A CLI tool to create directory structures from a structure file.

positional arguments:
  src              source file (with .tree extension)
  dst              where to create the tree structure (default: .)

options:
  -h, --help         show this help message and exit
  -cd, --create-dst  create destination folder if it does not exist.
  -g, --graphical    show source file as graphical tree and exit
  -o, --overwrite    overwrite existing files
  -s, --skip         skip existing files
  -v, --verbose      increase verbosity

Maketree 1.0.2

There is only one required argument that you need to provide, and that is src, a source file that defines the tree structure to create.

maketree parses the tree structure defined in a .tree file and then creates the directories and/or files on the filesystem. Let's create this structure file and name it myapp.tree.

src/
    index.css
    index.js

We want maketree to create a folder called src and two files in that folder namely index.css and index.js. Notice i've used 4 space indentation for nesting and a forward slash to mark src as a directory and not a file.

Defining a directory structure is fairly easy. You just write the names of folders and files you want to create, nest them as per you needs and that's it.

There are only three rules you must follow:

  1. Directories must end with a forward slash /

  2. Indentation must always be of 4 spaces (it tolerates other indentations but may produce unexpected results)

  3. And directory or file names must be valid according to your OS.

Let's add more files and folders in myapp.tree file.

node_modules/
public/
    favicon.ico
    index.html
    robots.txt
src/
    index.css
    index.js
.gitignore
package.json
README.md

Let's now create the structure on our filesystem:

>> maketree myapp.tree
3 directories and 8 files have been created.

maketree creates the structure in current directory by default. You can also provide a destination location to create the structure in that location.

Let's create a folder in our current directory called myapp using mkdir or just let maketree create it for use using -cd or --create-dst flag.

>> maketree myapp.tree myapp --create-dst
3 directories and 8 files have been created.

It created the structure in myapp folder.

But what if we run it again? without deleting the structure in myapp folder? Let's see.

>> maketree myapp.tree myapp
Warning: File 'app\public\favicon.ico' already exists
Warning: File 'app\public\index.html' already exists
Warning: File 'app\public\robots.txt' already exists
Warning: File 'app\src\index.css' already exists
Warning: File 'app\src\index.js' already exists
Warning: File 'app\.gitignore' already exists
Warning: File 'app\package.json' already exists
Warning: File 'app\README.md' already exists

Fix 8 issues before moving forward.

maketree won't overwrite existing files by default. It warns you which files already exist and quits.

But if you don't want to delete the files yourself or you just want maketree to overwrite them, You can give -o or --overwrite to overwrite existing files.

>> maketree myapp.tree myapp --overwrite
0 directories and 8 files have been created.

It overwrites existing files as expected.

There's also a -s or -skip flag that skips existing files and create non-existing ones.

Let's first delete all files in public folder.

>> rm myapp/public/*

Now let's re-run the maketree command (but this time, with --skip flag).

>> maketree myapp.tree myapp --skip
0 directories and 3 files have been created.

It skipped all files that already existed and created the ones that didn't.

You can also see a graphical representation of the tree structure in .tree file with '-g or --graphical command.

>> maketree myapp.tree -g
.
├─── node_modules
├─── public
│   ├─── favicon.ico
│   ├─── index.html
│   └─── robots.txt
├─── src
│   ├─── index.css
│   └─── index.js
├─── .gitignore
├─── package.json
└─── README.md

It makes it easy to see visualize the structure maketree will create on your filesystem.

The structure file can be as simple or complex as you want. There's no limit (well unless the OS you're using doesn't have any).

Compatibilty

maketree has been tested on Windows, Mac, and Linux (ubuntu) with python versions 3.8 upto 3.13.

Note:

maketree is in it's beta phase, so you may encounter some bugs. Please report if you do.

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

maketree-1.0.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

maketree-1.0.2-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file maketree-1.0.2.tar.gz.

File metadata

  • Download URL: maketree-1.0.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for maketree-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fa472af09765084fc8fe4e62e50219927eb8bf6e07d6e0af20758319f95dd0c8
MD5 49b2c12399cf38a7a71088d8b2922ca1
BLAKE2b-256 a800a41d62533a48d17078ab7a069714962a6ab97cab6830782051df21a95bf2

See more details on using hashes here.

File details

Details for the file maketree-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: maketree-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for maketree-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 390bb3b1c6f725ec9d12e8022d6f33e7fba6064ea57218ca07b4cee98f7c4308
MD5 4b9aa8b1cffea405c68378b7a045ad7c
BLAKE2b-256 4a322afc6ef14e33eea7549417a5967d71ebe0f658d1eaf941f4b2195ba54446

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