Skip to content

execution

EricGebhart edited this page Sep 27, 2021 · 2 revisions

Execution

The default process

In the configuration there is an exec/autoexec attribute. This should be a symbol name or list of symbol names to run as the default process. This is the process that will run when running in interactive loop mode, or when run once.

If symbols are given on the cli after the option then that list takes the place of the autoexec for that execution.

Modes of running

  • Run Autoexec once
  • Run the Autoexec in an intractive loop
  • Run a repl
  • Run command line args once
  • Run command line args in an intractive loop
  • Run command line args once and start the repl

Examples - mix and match.

  • SPR -i Run in a loop doing a process over and over
  • SPR Run a process once
  • SPR cmd1 cmd2 Run a list of command/symbols from the command line
  • SPR -f foo.spr Run an SPR file.
  • SPR -r Run as an interactive REPL
  • SPR -r cmds Run as an interactive REPL, executing cmds on startup.
  • SPR -rf foo.spr cmds Run as an interactive REPL, loading a file and executing cmds on startup.

Sources:

When run with no Arguments, SPR will try to do whatever is set as the autoexec in the configuration file. This setting should be a list of words understood by the interpreter.

With -f a file can be given for SPR to run on startup before the autoexec or repl is started.

The configuration file can also hold SPR code in the functions: section.

Additionally there are hooks which can be defined in the configuration to do what you like, at particular steps of the process.

Order of execution

  • Load module config - SPR-Defaults, SPRconfig.yaml

  • core.py

  • The autoload defined will first be loaded.

  • The Startup Hooks defined in the configuration will run.

  • The file given with -f will run next.

  • Run with a REPL,

    • Commands on the command line will execute on startup.
  • Run the Automatic Exec once or in a loop.

    • Commands given on the command line will replace the autoexec defined in the configuration file.
  • The Shutdown Hook defined in the configuration will run last

In any case, if any step fails, the process will fail. if in interactive loop mode, -i, The failure and continue dialogs will catch the fail for the next loop.

Clone this wiki locally