From: imeevma@tarantool.org
To: tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH v3 1/1] sql: tarantoolctl "enter" with set language
Date: Mon, 30 Jul 2018 11:33:33 +0300 [thread overview]
Message-ID: <ef6f6e422151ce7549f863e8b17577b28851383d.1532939582.git.imeevma@gmail.com> (raw)
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.
@TarantoolBot document
Title: Language selection for tarantoolctl
"enter".
User can select either Lua or SQL when he uses tarantoolctl
"enter" command. It can be done using "--language=<language>"
syntax. Default language is set in tarantoolctl config file.
Usage:
tarantoolctl enter <app_name> --language=SQL
tarantoolctl enter <app_name> --language=Lua
---
Branch: https://github.com/tarantool/tarantool/tree/imeevma/gh-2385-select-input-language-tarantoolctl
Issue: https://github.com/tarantool/tarantool/issues/2385
| 1 +
| 1 +
| 31 +++++++++++++++++++++++++++----
3 files changed, 29 insertions(+), 4 deletions(-)
--git a/extra/dist/CMakeLists.txt b/extra/dist/CMakeLists.txt
index 862689e..3045b5a 100644
--- a/extra/dist/CMakeLists.txt
+++ b/extra/dist/CMakeLists.txt
@@ -34,6 +34,7 @@ message (STATUS "tarantoolctl logdir: ${TARANTOOL_LOGDIR}")
set(TARANTOOL_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/tarantool")
message (STATUS "tarantoolctl rundir: ${TARANTOOL_RUNDIR}")
set(TARANTOOL_USER "tarantool")
+set(TARANTOOL_LANGUAGE "lua")
set(SYSCONFIG_AVAILABLEDIR "tarantool/instances.available")
set(SYSCONFIG_ENABLEDDIR "tarantool/instances.enabled")
set(TARANTOOL_AVAILABLEDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${SYSCONFIG_AVAILABLEDIR}")
--git a/extra/dist/default/tarantool.in b/extra/dist/default/tarantool.in
index 9a8dad3..01e7144 100644
--- a/extra/dist/default/tarantool.in
+++ b/extra/dist/default/tarantool.in
@@ -20,6 +20,7 @@ default_cfg = {
vinyl_dir = "@TARANTOOL_DATADIR@", -- @TARANTOOL_DATADIR@/${INSTANCE}
log = "@TARANTOOL_LOGDIR@", -- @TARANTOOL_LOGDIR@/${INSTANCE}.log
username = "@TARANTOOL_USER@",
+ language = "@TARANTOOL_LANGUAGE@",
}
-- instances.available - all available instances
--git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 2dd5d74..edda76d 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -47,6 +47,7 @@ local default_cfg
local positional_arguments
local keyword_arguments
local lua_arguments = arg
+local language
-- function for printing usage reference
local usage
@@ -155,6 +156,14 @@ 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')
+ language = (d.language or "lua"):lower()
+ d.language = nil
+
+ if language ~= "lua" and language ~= "sql" then
+ log.error('Unknown language: %s', language)
+ os.exit(1)
+ end
+
default_cfg = d
if not usermode then
@@ -629,6 +638,12 @@ local function logrotate()
end
local function enter()
+ local options = keyword_arguments
+ language = (options.language or language):lower()
+ if language ~= "lua" and language ~= "sql" then
+ log.error('Unknown language: %s', options.language)
+ return 1
+ end
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())
@@ -639,12 +654,15 @@ local function enter()
return 1
end
- local cmd = string.format(
+ local cmd_connect = string.format(
"require('console').connect('%s', { connect_timeout = %s })",
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_connect)
+ self:eval(cmd_language) end)
console.on_client_disconnect(function(self) self.running = false end)
console.start()
return 0
@@ -1008,11 +1026,15 @@ local commands = setmetatable({
}
}, enter = {
func = exit_wrapper(enter), process = process_local, help = {
- header = "%s enter INSTANCE",
+ header = "%s enter INSTANCE [--language=language]",
linkmode = "%s enter",
description =
[=[
- Enter an instance's interactive Lua console.
+ Enter an instance's interactive Lua or SQL console.
+
+ Supported options:
+ * --language=language to set interactive console language.
+ May be either Lua or SQL.
]=],
weight = 65,
deprecated = false,
@@ -1284,6 +1306,7 @@ do
{ 'chdir', 'string' },
{ 'only-server', 'string' },
{ 'server', 'string' },
+ { 'language', 'string' },
})
local cmd_name
--
2.7.4
next reply other threads:[~2018-07-30 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 8:33 imeevma [this message]
2018-07-30 10:39 ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-01 22:14 ` Vladislav Shpilevoy
2018-08-02 8:35 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef6f6e422151ce7549f863e8b17577b28851383d.1532939582.git.imeevma@gmail.com \
--to=imeevma@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v3 1/1] sql: tarantoolctl "enter" with set language' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox