Note
This documentation reflects the legacy implementation of stl. See Internal Details and Implementation for the current implementation.
Note
This document explains my rationale for writing the zsh version of stl in the way that I did. While this document may be useful for you as a legend for understanding this script, the truth is that the zsh stl is only useful as a prototype, and needs to be rewritten in a more modular and maintainable system. – tychoish
The goals in writing this script were:
stl begins with a number of reusable generic functions, and ends with a number of deployment specific functions that you’ll need to customize so that the script knows where to find your files and work. See the previous section for more information on how to customize the script for personal usage, and the code paths section for more information on how the interpreter processes the code.
This section provides an inventory, as they appear in the file, of each function and it’s general purpose.
notify-init configures the notification system, and creates a notify function that either logs the output of script to a logfile (i.e. “~/$PROJECT/stats.log”) or sends an xmpp message using an xmpp-notify script that is also included in the distribution.
The script will use the log file if:
Otherwise the script will send log messages to XMPP. Use a command in the following form to toggle XMPP/log file logging.
stl [domain] output xmpp
stl [domain] output logfile
Remember that you must configure your domain before running this command.
action-handler is a simple function that holds a case statement that calls another functions that does the actual work of the script.
stats-log allows users to create a number of entries in the log with arbitrary messages, to provide the build reports and word counts with context. stats-logs requires that you specify a start, stop, or note, followed by a message.
Output follows the system configuration for “logfile” or “xmpp” notifications.
build-report opens or outputs the contents of the last build of the specified project or projects. Use these options to check for build errors.
stats-base is the main worker function of stl, and it checks and returns word counts for projects primarily. Unless you include the “force” argument, this function will only return data if the value is different from the value when the script was last run. Every time the script runs, it checks against the last new value written in the “/tmp/$PROJECTS-stats/ folder.
compile-project triggers a rebuild or build of the project. It supports Sphinx (including sffms,) and Ikiwiki using git. The function writes the output of the build process to files in the “/tmp/$PROJECT-stats” folder, and logs completion via the notify function.
domain-selector is a function that sets sub-project specific variables before calling the “action-handler” function.
main the primary function of the code, and the only function that the main body of the script calls directly.