Module scaffold

A collection of functions that write things to a directory

Functions

unindent (input) Helper function to avoid messy indentation in source files.
buildpath (path) Creates a directory and all necessary parent directories.
delete (path) Deletes a file or directory recursively
file (buffer, file) Writes an arbitrarily nested sequence of strings to a file
builddir ([prefix="."], tab) Builds a directory structure recursively from a table template.
readdir (path) Reads a directory into a table


Functions

unindent (input)
Helper function to avoid messy indentation in source files. Removes whitespace up to and including the first non-whitespace character at the beginning of every line.

Parameters:

  • input string A multiline string to remve indentation from.

Usage:

    scaffold.unindent [[
    	|-- This file was generated automatically
    	|function do_things()
    	|	print "This Lua file is nicely formatted"
    	|end
    ]]
buildpath (path)
Creates a directory and all necessary parent directories.

Parameters:

  • path
delete (path)
Deletes a file or directory recursively

Parameters:

  • path string The path to the file or directory to delete
file (buffer, file)
Writes an arbitrarily nested sequence of strings to a file

Parameters:

  • buffer A string or nested sequence of strings to be written.
  • file file A file to write to (can be string or object with write method).

Returns:

    number The number of bytes that were written
builddir ([prefix="."], tab)
Builds a directory structure recursively from a table template.

Parameters:

  • prefix string A prefix to the path, aka. where to initialize the directory structure. (default ".")
  • tab table A table representing the directory structure. Table entries are subdirectories, strings are files, false means delete, true means touch file, everything else is an error.

Usage:

    builddir {
    	sub_dir = {
    		file = 'Hello World!'; -- new file
    	}
    	empty = true; -- new empty file
    	delete_me = false; -- will be deleted
    }
readdir (path)
Reads a directory into a table

Parameters:

  • path
generated by LDoc 1.4.6 Last updated 2022-11-23 12:50:54