-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start apicast console and optionally execute a file
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
local setmetatable = setmetatable | ||
|
||
local _M = { } | ||
local mt = { __index = _M } | ||
|
||
local function configure(cmd) | ||
cmd:argument('file', 'file to execute'):args("?") | ||
return cmd | ||
end | ||
|
||
function _M.new(parser) | ||
local cmd = configure(parser:command('console', 'Start console')) | ||
|
||
return setmetatable({ parser = parser, cmd = cmd }, mt) | ||
end | ||
|
||
function mt:__call(options) | ||
local repl = require('resty.repl') | ||
|
||
_G.repl = repl.start | ||
|
||
function _G.reload() package.loaded = {} end | ||
|
||
if options.file then | ||
dofile(options.file) | ||
end | ||
|
||
repl.start() | ||
end | ||
|
||
return setmetatable(_M, mt) |