Skip to content

Run Scripts From the Command Line

Foxel can execute a script directly from the command line.

This is useful when you want to automate tasks or integrate Foxel into external workflows.

Why This Matters

Running scripts from inside Foxel is useful for interactive work.

Running scripts from the command line is useful when Foxel should become part of a larger automated workflow.

Use command-line scripting when scripts should be triggered from outside the app, such as from batch files, build steps, or other automation tools.

Command Format

Run Foxel with the -run argument:

text
path\to\Foxel.exe -run scriptname

The script argument can be one of the following:

  • The name of a shared script as it appears in Foxel.
  • The full path to a .lua script file.

Shared script names are matched case-insensitively.

Examples

To run a shared script:

text
C:\Program Files\Foxel\Foxel.exe -run MyScript

To run a script from a file path:

text
C:\Program Files\Foxel\Foxel.exe -run "C:\[Scripts](/manual/shared-files/scripts)\MyScript.lua"

Use quotes around paths that contain spaces.

What Foxel Does In Command-Line Mode

When started in command-line mode, Foxel:

  1. Opens.
  2. Executes the script.
  3. Closes automatically after the script finishes.

A window and rendering context are still created.

This allows scripts to perform operations that require the normal application context, including operations that depend on rendering or scene processing.

Exit Codes

Foxel returns exit codes after command-line script execution.

Exit CodeMeaning
0Script executed successfully
102Script file was not found
902Script execution failed

These exit codes are useful in:

  • Batch files
  • Build pipelines
  • External automation tools
  • Continuous processing workflows

Use them to detect whether the script completed successfully or failed.

Example Script

A very small script example is:

lua
FxLog = require "FxLog"
FxLog.WriteTrace("Hello World!")

This loads the FxLog module and writes a trace message.

When To Use Command-Line Scripts

Command-line scripts are useful when Foxel should be part of a repeatable external process.

For example, use them when you want to:

  • Run a scripted setup step.
  • Process assets from a batch file.
  • Integrate Foxel into a build pipeline.
  • Run the same script without manually opening the app.
  • Let another tool trigger Foxel automation.

For interactive work, running scripts from the Action Bar may be more convenient.

For external automation, command-line execution is the better fit.

What To Remember

  • Use -run to execute a Foxel script from the command line.
  • The argument can be a shared script name or a full .lua path.
  • Shared script names are matched case-insensitively.
  • Use quotes around file paths that contain spaces.
  • Foxel opens, runs the script, and closes automatically.
  • A window and rendering context are still created.
  • Exit codes help external automation detect success or failure.