diff --git a/CHANGELOG.md b/CHANGELOG.md index 7208f0a20..5b7260fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Rewrite URL captures policy. This policy captures arguments in a URL and rewrites the URL using them [PR #827](https://github.com/3scale/apicast/pull/827), [THREESCALE-1139](https://issues.jboss.org/browse/THREESCALE-1139) - Support for HTTP Proxy [THREESCALE-221](https://issues.jboss.org/browse/THREESCALE-221), [#709](https://github.com/3scale/apicast/issues/709) - Conditions for the limits of the rate-limit policy [PR #839](https://github.com/3scale/apicast/pull/839) +- `bin/apicast console` to start Lua REPL with APIcast code loaded [PR #853](https://github.com/3scale/apicast/pull/853) ### Changed diff --git a/gateway/src/apicast/cli.lua b/gateway/src/apicast/cli.lua index 7f5548be7..19b7bca3e 100644 --- a/gateway/src/apicast/cli.lua +++ b/gateway/src/apicast/cli.lua @@ -23,6 +23,7 @@ end _M.commands = load_commands({ 'start', 'generate', + 'console', }, parser) function mt.__call(self, arg) diff --git a/gateway/src/apicast/cli/command/console.lua b/gateway/src/apicast/cli/command/console.lua new file mode 100644 index 000000000..aaca00ac0 --- /dev/null +++ b/gateway/src/apicast/cli/command/console.lua @@ -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)