Module pl.app

Application support functions.

Functions

appfile (file) return a suitable path for files private to this application.
parse_args (args, flags_with_values) parse command-line arguments into flags and parameters.
require_here () add the current script's path to the Lua module path.


Functions

appfile (file)
return a suitable path for files private to this application. These will look like '~/.SNAME/file', with '~' as with expanduser and SNAME is the name of the script without .lua extension.

Parameters:

  • file: a filename (w/out path)

Return value:

    a full pathname
parse_args (args, flags_with_values)
parse command-line arguments into flags and parameters. Understands GNU-style command-line flags; short (-f) and long (--flag). These may be given a value with either '=' or ':' (-k:2,--alpha=3.2,-n2); note that a number value can be given without a space. Multiple short args can be combined like so: (-abcd).

Parameters:

  • args: an array of strings (default is the global 'arg')
  • flags_with_values: any flags that take values, e.g. {out=true}

Return values:

  1. a table of flags (flag=value pairs)
  2. an array of parameters
require_here ()
add the current script's path to the Lua module path. Applies to both the source and the binary module paths. It makes it easy for the main file of a multi-file program to access its modules in the same directory.

Return value:

    the current script's path with a trailing slash

Valid XHTML 1.0!