Workcraft command line usage is as follows workcraft [OPTIONS] [FILES]
OPTIONS
– space-separated list of the following options:-dir:DIR
– path to the working directory-config:CONFIG
– user config file (default is global config.xml
) since v3.3.6-config-add:CONFIG
– additional read-only config file to override user config settings since v3.3.8-exec:SCRIPT
– JavaScript file or one-liner to execute on startup-port:PORT
– reuse running instance on PORT
to open FILES
-nogui
– run in console mode-noconfig-load
– use default settings instead of loading them from user config since v3.3.8-noconfig-save
– do not overwrite user config on exit since v3.3.8-noconfig
– use default settings and do not overwrite user config-version
– report the version information and exit-help
– display this help message and exitFILES
– space-separated list of work files to open or arguments for SCRIPT
Note that file path parameters CONFIG
, SCRIPT
and FILES
are relative to the working directory.
since v3.3.8 Use environment variables WORKCRAFT_CONFIG
and WORKCRAFT_CONFIG_ADD
as lower priority alternatives to command line options -config:
and -config-add:
respectively.
since v3.4.0 To run Workcraft with a specific version of Java Runtime Environment supply it in jre
subdirectory of Workcraft installation. If this directory is not found or if WORKCRAFT_USE_NATIVE_JAVA
environment variable is defined, then a natively installed Java is used.
If your command line refers to a path containing spaces or other suspicious symbols, then surround it by quotation marks (both '
and "
are supported). For example, if you want to set a working directory to "C:\Workcraft Projects" and run a script "Example scripts\test1.js" in there, then Windows command line would look as follows:
workcraft.bat -nogui -dir:"C:\Workcraft Projects" -exec:'Example scripts\test1.js'
Note that backslash symbols \
in scripts (e.g. in a Windows file path) need to be escaped as in this example (notice the double backslashes):
work = load("models\\test1.work"); stat = statModel(work); write(stat, "C:\\Temp\\test1.txt"); exit();
Alternatively, Unix-style file hierarchy separator /
can be used, as it does not require escaping and is recognised in all Linux, OSX and Windows:
work = load("models/test1.work"); stat = statModel(work); write(stat, "C:/Temp/test1.txt"); exit();
In the above examples "Example scripts\test1.js" and "models\test1.work" are relative to the working directory "C:\Workcraft Projects", while the file "C:\Temp\test1.txt" is specified by its absolute path.
workcraft -nogui -noconfig -exec:'/path/to/script.js'
workcraft -nogui -noconfig -exec:script.js -dir:'/path/to/working/directory/'
workcraft -nogui -exec:'print("Hello!");exit();'
workcraft -noconfig-load
workcraft -config-add:config-specific.xml
workcraft -config:config-base.xml -config-add:config-specific.xml -noconfig-save
export WORKCRAFT_CONFIG=config-new.xml export WORKCRAFT_CONFIG_ADD=config-specific.xml workcraft -noconfig-load
In order to reuse the same instance of Workcraft for opening .work
files from a command line use -port:NUMBER
option. This will enable Workcraft to check if its instance is already running and listening on that port, and if this is the case, pass data to the running instance via the specified port.
For example, the following sequence of commands would first start Workcraft on port 12345, then open file.work, and finally execute script.js, all in the same instance of Workcraft (so script.js can refer for model in file.work):
workcraft -port:12345 workcraft -port:12345 file.work workcraft -port:12345 -exec:script.js
This feature is is also convenient when associating .work
files with Workcraft, so they can be open directly from a file browser. By default, a new instance of Workcraft would start each time a .work
file is open this way. If you prefer to reuse a single instance of Workcraft, this can be achieved by hard-coding an unoccupied port number directly into workcraft
runner script (e.g. add -port:12345
just before -dir:
option).