On 25/07/2018 10:51, imeevma@xxxxxxxxxxxxx wrote:
This patch allow to use option "--language" with
"tarantoolctl enter" command. Also default value
for language were added in default configuration
file. Language is either SQL or Lua.
Closes #2385.
---
Branch:
https://github.com/tarantool/tarantool/tree/imeevma/gh-2385-select-input-language-tarantoolctl
Issue: https://github.com/tarantool/tarantool/issues/2385
diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 2dd5d74..55711b8 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -155,6 +155,11 @@ local function load_default_file(default_file)
d.vinyl_dir = fio.pathjoin(d.vinyl_dir, instance_name)
d.log = fio.pathjoin(d.log, instance_name .. '.log')
+ d.language = (d.language or "lua"):lower()
+ if d.language ~= "lua" and d.language ~= "sql" then
+ d.language = "lua"
+ end
+
default_cfg = d
if not usermode the> @@ -629,6 +635,17 @@ local function logrotate()
end
local function enter()
+ local options = keyword_arguments
+ local language = options.language
+ if language ~= nil then
+ language = language:lower()
+ if language ~= "lua" and language ~= "sql" then
+ log.warn("Language \"%s\" is not recognized. Default language" ..
+ " \"%s\" is set.", language, default_cfg.language)
+ language = nil
+ end
+ end
+ language = language or default_cfg.language
local console_sock_path = uri.parse(console_sock).service
if fio.stat(console_sock_path) == nil then
log.error("Can't connect to %s (%s)", console_sock_path,
errno.strerror())
@@ -644,7 +661,9 @@ local function enter()
console_sock, TIMEOUT_INFINITY
)
- console.on_start(function(self) self:eval(cmd) end)
+ local cmd_language = string.format("\\set language %s", language)
+
+ console.on_start(function(self) self:eval(cmd) self:eval(cmd_language) end)
console.on_client_disconnect(function(self) self.running = false end)
console.start()
return 0
@@ -1284,6 +1303,7 @@ do
{ 'chdir', 'string' },
{ 'only-server', 'string' },
{ 'server', 'string' },
+ { 'language', 'string' },
})
local cmd_name