Module pl.app
Application support functions.
See the Guide
Functions
require_here () | add the current script's path to the Lua module path. |
appfile (file) | return a suitable path for files private to this application. |
platform () | return string indicating operating system. |
parse_args (args, flags_with_values) | parse command-line arguments into flags and parameters. |
Functions
- 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.
Returns:
-
the current script's path with a trailing slash
- 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)
Returns:
-
a full pathname
- platform ()
-
return string indicating operating system.
Returns:
-
'Windows','OSX' or whatever uname returns (e.g. 'Linux')
- 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}
Returns:
- a table of flags (flag=value pairs)
- an array of parameters