TuPrologCmd
Root clikt command of the 2P-Kt REPL: java -jar 2p-repl.jar.
Run with no subcommand, it starts an interactive Prolog read-eval-print loop: it builds a it.unibo.tuprolog.solve.Solver (see getSolver), repeatedly prompts the user for a dot-terminated query with ?- (see AbstractTuPrologCommand.readQuery), parses it with it.unibo.tuprolog.core.Struct.Companion.parse, solves it, and prints the resulting solutions -- until the standard input stream is closed, at which point it prints a farewell message and exits.
Supported options (see the corresponding property for details): -T/--theory (repeatable, one or more theory files to load into the static KB), -t/--timeout (per-query solving timeout, in milliseconds), and --oop (also load :oop-lib's it.unibo.tuprolog.solve.libs.oop.OOPLib). The solve subcommand (TuPrologSolveQuery) reuses the same solver to evaluate a single query non-interactively instead.
The solver is always built with :io-lib's it.unibo.tuprolog.solve.libs.io.IOLib loaded (for write/1, nl/0, file inclusion, and the like -- see IOLib's own KDoc for the full predicate list), on top of it.unibo.tuprolog.solve.classic.ClassicSolverFactory's ISO-standard resolution engine (via it.unibo.tuprolog.solve.Solver.Companion.prolog).
Parameters
extra Library instances to load into the solver alongside IOLib (and OOPLib when --oop is given), e.g. for an embedder that wants to expose custom predicates through this same CLI.
Properties
Functions
Builds a fresh Solver according to this command's options: it loads and merges every theory file given via -T/--theory (skipping any that isReadableFile deems unreadable, and reporting a it.unibo.tuprolog.core.parsing.ParseException for any that fails to parse) into the static knowledge base, always loads :io-lib's it.unibo.tuprolog.solve.libs.io.IOLib plus this command's additionalLibraries, additionally loads :oop-lib's it.unibo.tuprolog.solve.libs.oop.OOPLib when --oop was given, enables the it.unibo.tuprolog.solve.flags.TrackVariables flag, and routes solve warnings to the terminal (with their logic stack trace). As a side effect, it echoes the 2P-Kt version and the alias of each loaded library to standard output.
The -t/--timeout option's value (milliseconds, defaulting to DEFAULT_TIMEOUT), converted to the TimeDuration expected by it.unibo.tuprolog.solve.Solver.solve. Exposed so TuPrologSolveQuery can reuse the same timeout its parent command was configured with.
Builds a solver (see getSolver) and, if no subcommand was invoked on the command line, starts the interactive read-eval-print loop with it. When a subcommand (e.g. solve) was invoked instead, clikt dispatches to that subcommand's own run after this method returns, reusing the solver built here through getSolver/getTimeout.