CommandBox contains a REPL
command which is a powerful tool to execute ad-hoc CFML code from the command line. A REPL reads user input, evaluates it, prints the result, and then repeats the process. The CommandBox REPL supports the inline execution of both CF script or tags.
The default mode of the REPL
command is to accept script. You can enter most any CF Script into the prompt for execution. If the script is an expression that returns a value, or sets a variable, that value/variable will be output. Variables that you set will be available to you until you exit the REPL
command.
Multi-line statements are also allowed. If you have typed a starting {
without an ending }
, the REPL will keep accepting lines until it has determined the statement to be finished. The prompt changes to ...
until the statement is finished.
If you would like to abort a multi-line statement, simply type exit
at the prompt.
You can also enter tags at the REPL. Switch to this mode by setting the script
flag to false.
Any output from the tags will be returned to the console.
Multi-line statements are not currently supported in the tag REPL.
The script and tag REPL have their only history. Use the up
and down
arrows to access previous things you typed. Your REPL history can be viewed and managed by the history
command (once you exit the REPL).
Tab completion is currently not supported in either of the REPLs.