This library is intended for supporting PrologScript on Unix using the
#! magic sequence for scripts using commandline options. The entry
point main/0 calls the user-supplied predicate main/1 passing a list of
commandline options. Below is a simle
echo implementation in Prolog.
:- initialization(main, main).
echo() :- nl.
echo([Last]) :- !,
write(H), write(' '),
- See also
- - library(optparse) for comprehensive option parsing.
- - library(prolog_stack) to force backtraces in case of an
- - XPCE users should have a look at library(pce_main), which
starts the GUI and processes events until all windows have gone.
- Call main/1 using the passed command-line arguments. Before calling
main/1 this predicate installs a signal handler for
(Control-C) that terminates the process with status 1.
- argv_options(+Argv, -RestArgv, -Options) is det
- Generic transformation of long commandline arguments to options.
Each --Name=Value is mapped to Name(Value). Each plain name is
mapped to Name(true), unless Name starts with
no-, in which
case the option is mapped to Name(false). Numeric option values
are mapped to Prolog numbers.
- See also
- - library(optparse) provides a more involved option library,
providing both short and long options, help and error handling.
This predicate is more for quick-and-dirty scripts.
- cli_parse_debug_options(+OptionsIn, -Options) is det
- Parse certain commandline options for debugging and development
purposes. Options processed are below. Note that the option
argument is an atom such that these options may be activated as
debug(Topic). See debug/1 and debug/3.
- spy Predicate
- Place a spy-point on Predicate.
- As spy using the graphical debugger. See tspy/1.
- Start the Prolog toplevel after main/1 completes.
- Re-enable the development environment. Currently re-enables xpce if
this was loaded, but not initialised and causes the interactive
toplevel to be re-enabled.
This predicate may be called from main/1 to enter the Prolog
toplevel rather than terminating the application after main/1