2.11.1.5 SWI-Prolog app scripts
As of version 9.1.18, SWI-Prolog allows starting an application using the command below.
swipl [option ...] [path:]name [arg ...]
This command line first processes Prolog options described in
section 2.4. Note that
most standard Prolog commandline options are not relevant. The -f
defaults to none
, which implies that the user init file is
by default not loaded. If an application wishes to load the user init
file, it should load
user_app_config(init)
if this file exists (see
exists_source/1).
Next, it locates path(name)
using SWI-Prolog's file
search mechanism defined by absolute_file_name/3.
After loading this file it finds the last goal registered for main
using initialization/2
as described in section
2.11 - if there is no initization directive for main
,
the program terminates with an error. By default, the application
terminates after the entry point terminates. The entry point may enable
the interactive Prolog REPL loop by calling
cli_enable_development_system/0.
Other forms of the initialization/2
directive are also allowed, in addition to‘main`.
All command line options after [path:]name
are
accessible in the Prolog flag argv.
The optional path defaults to app
. By
default, apps are searched in the directories below. See file_search_path/2
for details.
- The
app
directory of the SWI-Prolog installation - User and site configuration. On POSIX systems using the XDG file
name conventions, this is normally
/.local/share/swi-prolog/app/
and/usr/share/swi-prolog/app
. - The
app
directory of a Prolog pack.
The following apps are provided by the installation
- app
- Print information on installed apps. For example, to list all available
apps, run
swipl app list
- pack
- Command line driven management of Prolog packs. This is a front-end to
the Prolog library
library(prolog_pack)
. For example, to find packages related to type, use the command below.swipl pack find type