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:
path\to\Foxel.exe -run scriptnameThe script argument can be one of the following:
- The name of a shared script as it appears in Foxel.
- The full path to a
.luascript file.
Shared script names are matched case-insensitively.
Examples
To run a shared script:
C:\Program Files\Foxel\Foxel.exe -run MyScriptTo run a script from a file path:
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:
- Opens.
- Executes the script.
- 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 Code | Meaning |
|---|---|
0 | Script executed successfully |
102 | Script file was not found |
902 | Script 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:
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
-runto execute a Foxel script from the command line. - The argument can be a shared script name or a full
.luapath. - 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.