Skip to content

Use Ctrl+C to discard the input in console #3113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions doc/reference/interactive_console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ or start :ref:`tarantoolctl <tarantoolctl>` with ``enter``.
The interactive console is often called the Lua console to distinguish it from the administrative console,
but in fact it can handle both Lua and SQL input.

The majority of examples in this manual show what users see with the
interactive console, including the prompt (which can be ``tarantool>``),
the instruction (which can be a Lua request or an SQL statement),
and the response (which can be a display in either YAML format or Lua format).
The majority of examples in this manual show what users see with the interactive console.
It includes:

* ``tarantool>`` prompt
* instruction (a Lua request or an SQL statement)
* response (a display in either YAML or Lua format)

.. code-block:: none

-- Typical interactive console example with Lua input and YAML output
-- Interactive console example with Lua input and YAML output
tarantool> box.info().replication
---
- 1:
Expand All @@ -28,19 +30,22 @@ and the response (which can be a display in either YAML format or Lua format).
lsn: 0
...

.. _interactive_console_input_output:

Interactive console input and output
------------------------------------

The **input language** can be changed to SQL with ``\set language sql``
or changed to Lua (the default) with ``\set language lua``.

The **delimiter** can be changed to any character with :samp:`\set delimiter <character>`.
The default is nothing, which means input does not need to end with a delimiter.
But a common recommendation is to say ``set delimiter ;`` especially if input is SQL.

.. _interactive_console_output:

The **output format** can be changed to Lua with ``\set output lua``
or changed to YAML (the default) with ``\set output yaml``.

Ordinarily. output from the console has `YAML format <http://yaml.org/spec>`_.
Ordinarily, output from the console has `YAML format <http://yaml.org/spec>`_.
That means that there is a line for document-start ``"---"``,
and each item begins on a separate line starting with ``"- "``,
and each sub-item in a nested structure is indented,
Expand All @@ -54,7 +59,7 @@ So, when input is a Lua object description, output will equal input.

YAML is good for readability.
Lua is good for re-using results as requests.
A third format, MsgPack, is good for database storage.
The third format, MsgPack, is good for database storage.
Currently the default output format is YAML but it may be Lua in a future version,
and it may be Lua if
the last :ref:`set_default_output <console-set_default_output>`
Expand Down Expand Up @@ -120,3 +125,30 @@ call was ``console.set_default_output('lua')``.
| :code:`...`

- :code:`\x81 \xa3 \x6b \x65 \x79 \x01`

.. _interactive_console-shortcuts:

Keyboard shortcuts
------------------

Since :doc:`2.10.0 </release/2.10.0>`.

.. list-table::
:widths: 25 75
:header-rows: 1

* - Keyboard shortcut
- Effect

* - ``CTRL+C``
- Discard current input with the ``SIGINT`` signal in the console mode and
jump to a new line with a default prompt.

* - ``CTRL+D``
- Quit Tarantool interactive console.

.. important::

Keep in mind that ``CTRL+C`` shortcut will shut Tarantool down if there is any currently running command
in the console.
The :ref:`SIGINT <admin-server_signals>` signal stops the instance running in a daemon mode.
2 changes: 1 addition & 1 deletion doc/reference/reference_lua/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Below is a list of all ``console`` functions.
The output format can be changed within a session by executing
:samp:`console.eval('\\\\set output {yaml}|{lua}')`; see the
description of output format in the
:ref:`Interactive console <interactive_console_output>` section.
:ref:`Interactive console <interactive_console_input_output>` section.

.. _console-eos:

Expand Down