Skip to content

Commit

Permalink
allow using .lua file extension in the command line
Browse files Browse the repository at this point in the history
* e.g., lunatik [run|stop] <script>.lua
  • Loading branch information
lneto committed Sep 23, 2024
1 parent 738c29f commit 0bc550b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/lunatik/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ local env = lunatik._ENV

local runner = {}

local function trim(script) -- drop ".lua" file extension
return script:gsub("(%w+).lua", "%1")
end

function runner.run(script, ...)
local script = trim(script)
if env.runtimes[script] then
error(string.format("%s is already running", script))
end
Expand All @@ -36,6 +41,7 @@ local function stop(registry, script)
end

function runner.stop(script)
local script = trim(script)
stop(env.threads, script)
stop(env.runtimes, script)
end
Expand Down

0 comments on commit 0bc550b

Please sign in to comment.