From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id BF6A124515 for ; Thu, 5 Sep 2019 17:29:17 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pLav0DgjLJyA for ; Thu, 5 Sep 2019 17:29:17 -0400 (EDT) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 61A7B244FF for ; Thu, 5 Sep 2019 17:29:17 -0400 (EDT) Received: by mail-lj1-f195.google.com with SMTP id d5so3993682lja.10 for ; Thu, 05 Sep 2019 14:29:17 -0700 (PDT) From: Cyrill Gorcunov Subject: [tarantool-patches] [PATCH 5/6] box/console: Provide console.eos() api Date: Fri, 6 Sep 2019 00:28:14 +0300 Message-Id: <20190905212815.7311-6-gorcunov@gmail.com> In-Reply-To: <20190905212815.7311-1-gorcunov@gmail.com> References: <20190905212815.7311-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tml Cc: Konstantin Osipov , Alexander Turenko , Cyrill Gorcunov The other modules would be able to find out which eos marker is currently active. For example when reading replies from remote server via text based console protocol. @TarantoolBot document Title: > require('console').eos() Returns a string with currently active end of string marker. @TarantoolBot document Title: > require('console').eos("") Sets end of string marker for appliable output modes. YAML output mode does not support eos change. For Lua mode it is possible to set eos to empty string (like in example above) or any other symbol. Note that default semicolon symbol is mandatory for remote text consoles thus if get zapped the read procedure from remote socket will not be possible and connection get stuck forever. Use this ability with extreme caution. Part-of #3834 --- src/box/lua/console.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) v3: - Don't use ... in arguments but rather name it eos_value diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index a6ff0e659..c1e8daaf8 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -164,6 +164,21 @@ local function current_eos() return output_eos[current_output()["fmt"]] end +local function console_eos(eos_value) + if not eos_value then + return tostring(current_eos()) + end + -- We can't allow to change yaml eos format because + -- it is a part of encoding standart, thus permit + -- only for modes where it is safe. + local d = current_output() + if d["fmt"] == "lua" then + output_eos["lua"] = eos_value + else + error("console.eos(): is immutable for output " .. d["fmt"]) + end +end + -- -- Map output format descriptor into a "\set" command. local function output_to_cmd_string(desc) @@ -792,6 +807,7 @@ package.loaded['console'] = { delimiter = delimiter; set_default_output = set_default_output; get_default_output = get_default_output; + eos = console_eos; ac = ac; connect = connect; listen = listen; -- 2.20.1