REPL
ptool repl starts an interactive Lua session with the standard ptool API
already loaded.
Start the REPL
ptool repl
When the REPL starts, ptool shows a banner and waits for Lua input.
What it provides
- The global
ptooltable and the shorter aliasp. - The same bundled helpers you can use from
ptool run <file>. - Interactive evaluation of Lua expressions and statements.
- Readline-style editing, including arrow-key cursor movement and in-session history navigation.
Basic usage
Enter an expression to evaluate it immediately:
1 + 2
The REPL prints returned values using the same inspector used elsewhere in
ptool.
You can also call ptool APIs directly:
p.str.trim(" hello ")
Multi-line input
If the current input is incomplete, the prompt changes from >>> to ... .
This lets you continue entering a block such as a function or control flow
statement:
for i = 1, 3 do
print(i)
end
Once the input is complete, ptool evaluates the whole chunk.
Keyboard behavior
UpandDownbrowse commands entered earlier in the same REPL session.LeftandRightmove the cursor within the current input line.Ctrl-Cclears the current input. If you are in the middle of a multi-line chunk, it discards the buffered chunk and returns to the primary prompt.Ctrl-Dexits the REPL.
Notes
ptool replrequires an interactive TTY.- REPL history currently lives only for the current session and is not written to a history file.