Skip to content

Commit

Permalink
Merge pull request #493 from evo-lua/eval-usage-information
Browse files Browse the repository at this point in the history
Add some usage instructions to the interpreter's "live edit" (REPL) interface
  • Loading branch information
Duckwhale committed Feb 9, 2024
2 parents ba5c5db + 5fcb091 commit 09368ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion Runtime/evo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ A list of supported profiling modes and their combinations can be found here: %s
transform.brightYellow("LUAJIT_PROFILEFILE=results.txt evo profile script.lua ..."),
transform.brightBlue("https://luajit.org/ext_profiler.html")
),
REPL_WELCOME_TEXT = format(
transform.brightGreen("Welcome to Evo.lua %s (REPL powered by LuaJIT)"),
EVO_VERSION
),
REPL_USAGE_INSTRUCTIONS = format(
"Evaluating code in %s mode. To exit, press %s or type %s.",
transform.brightMagenta("live edit"),
transform.brightYellow("CTRL+C"),
transform.brightYellow("os.exit()")
),
},
}

Expand Down Expand Up @@ -355,7 +365,8 @@ function evo.evaluateChunk(commandName, argv)
local luaCodeToEvaluate = unpack(argv)

if not luaCodeToEvaluate then
printf(transform.brightGreen("Welcome to Evo.lua %s (REPL powered by LuaJIT)"), EVO_VERSION)
print(evo.messageStrings.REPL_WELCOME_TEXT)
print(evo.messageStrings.REPL_USAGE_INSTRUCTIONS)
runtime.bindings.runtime_repl_start()
return
end
Expand Down
9 changes: 6 additions & 3 deletions Tests/snapshot-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ local testCases = {
.. SHELL_ESCAPE_SYMBOL
.. " | evo eval",
onExit = function(observedOutput, status, terminationReason, exitCodeOrSignalID)
local welcomeText =
transform.brightGreen(format("Welcome to Evo.lua %s (REPL powered by LuaJIT)", EVO_VERSION))
local expectedOutput = welcomeText .. "\n" .. "> Hello from the REPL!" .. "\n"
local expectedOutput = evo.messageStrings.REPL_WELCOME_TEXT
.. "\n"
.. evo.messageStrings.REPL_USAGE_INSTRUCTIONS
.. "\n"
.. "> Hello from the REPL!"
.. "\n"
assertEquals(observedOutput, expectedOutput)
assertExitFailure(observedOutput, status, terminationReason, exitCodeOrSignalID)
end,
Expand Down

0 comments on commit 09368ee

Please sign in to comment.