8000 GitHub - foundling/superdir: text become dir.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

foundling/superdir

Repository files navigation

Build Status

PyPI version

superdir_header

superdir is a command-line tool for Linux and OSX that generates a directory tree from a reasonable, consistently-indented flat file representation. It is MIT-licensed.

Installation:

pip install superdir

Dependencies

click

Usage:

Usage: superdir [OPTIONS] SCHEMA_FILE

Options:
  -o, --outfile TEXT  Filename of the directory to contain your superdir'd
                      files
  -c, --config TEXT   Config file to read before superdir'ing your schema
  -h, --help          Show this message and exit.

Contributing

See here for the contributors guide.

Motivation:

superdir is a simple and quick way to generate a directory structure without code. All you need is a schema file that you can generate yourself or copy from a tutorial you're following along with. Pipe it to superdir or pass it as a filename argument, and off you go.

Behavior:

  • superdir will not overwrite any existing files or directories and creates the directory structure from your schema only if it passes validation.
  • By default, lines that end with '/' are treated as directories. Everything else is treated as a file.
  • Comments should be prefixed by '#'.
  • Comments and blank lines are ignored.
  • If no OUTPUT_DIR option is given, the schema must contain exactly one top-level directory with no sibling files.
  • If an OUTPUT_DIR option is given, the schema file may contain one or more top-level directories and or files.

Hooks:

Hooks will let you copy a pre-existing file's content into a file created from your schema. To take advantage of hooks, pass the -c or --config flag with a filepath relative to your $HOME directory. In the config file, add an equal-delimited list of key-value pairs, where the key is the filename and the value is the filepath for the file you want to copy. Here's an example:

# config file in $HOME/.superdir_hooks 

# pattern to match from schema -> template location 
index.html = ~/apps/lib/html/index.html
styles.css = ~/apps/lib/css/styles.css

In the process of building the tree, if superdir comes across a matching file key, it will write the corresponding content from the file into the file tree's resulting file.

superdir in action!

# this a valid schema file
$ cat schema.txt
superdir/
    docs/
    # comments and blank lines are ignored
    superdir/
        superdir.py
        validator.py
        tree.py
    test/
        superdir_test.py
        validator_test.py
        tree_test.py
    README.md
    LICENSE.md
    test/

# creating a directory tree from the schema file
$ superdir schema.txt -o new_project && tree new_project 
new_project
└── superdir/
    └── docs/
    └── superdir/
        └── superdir.py
        └── validator.py
        └── tree.py
    └── test/
        └── superdir_test.py
        └── validator_test.py
        └── tree_test.py
    └── README.md
    └── LICENSE.md

# Piping schema.txt into superdir 
$ cat schema.txt | superdir -o another_new_project && tree another_new_project
another_new_project
└── superdir/
    └── docs/
    └── superdir/
        └── superdir.py
        └── validator.py
        └── tree.py
    └── test/
        └── superdir_test.py
        └── validator_test.py
        └── tree_test.py
    └── README.md
    └── LICENSE.md

About

text become dir.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0