Skip to content

Add tt CLI docs #2973

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 26 commits into from
Jul 8, 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
1 change: 1 addition & 0 deletions doc/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ Reference
../dev_guide/internals/index
../book/box/limitations
interactive_console
tt_cli/index
tarantoolctl
lua_tips
35 changes: 35 additions & 0 deletions doc/reference/tt_cli/arguments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Arguments
=========

``tt`` has the following arguments:

.. container:: table

.. list-table::
:widths: 40 60
:header-rows: 0

* - ``--cfg=FILE``

``-c=FILE``
- Path to the :ref:`configuration file <tt-config_file>`.
* - ``--internal``

``-i``
- Force the use of an internal module even if there is an external module with the same name.

.. // TODO: add link to external modules doc page when it's ready
* - ``--local=DIRECTORY``

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I don't know if that's normal or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed the layout


``-L=DIRECTORY``
- Use the ``tt`` environment from the specified directory.
Learn more about the :ref:`local launch mode <tt-config_modes-local>`.
* - ``--system``

``-S``
- Use the ``tt`` environment installed in the system.
Learn more about the :ref:`system launch mode <tt-config_modes-system>`.
* - ``--help``

``-h``
- Display help.
38 changes: 38 additions & 0 deletions doc/reference/tt_cli/commands.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Commands
========

Below is a list of `tt` commands. Run ``tt COMMAND help`` to see the detailed
help for the given command.

.. container:: table

.. list-table::
:widths: 30 70
:header-rows: 0

* - ``start``
- Start a Tarantool :ref:`instance <admin-instance_file>`
* - ``stop``
- Stop a Tarantool instance
* - ``status``
- Get the current status of a Tarantool instance
* - ``restart``
- Restart a Tarantool instance
* - ``version``
- Show the ``tt`` version information
* - ``completion``
- Generate autocompletion for a specified shell
* - ``help``
- Display help for ``tt`` or a specific command
* - ``logrotate``
- :ref:`Rotate logs <admin-logs>`
* - ``check``
- Check an application file for syntax errors
* - ``connect``
- Connect to a Tarantool instance
* - ``rocks``
- Use the LuaRocks package manager
* - ``cat``
- Print the contents of ``.snap`` or ``.xlog`` files into stdout
* - ``play``
- Play the contents of ``.snap`` or ``.xlog`` files to another Tarantool instance
107 changes: 107 additions & 0 deletions doc/reference/tt_cli/configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Configuration
=============

.. _tt-config_file:

Configuration file
------------------

The key artifact that defines the ``tt`` environment and various aspects of its
execution is its configuration file.

By default, the configuration file is called ``tarantool.yaml``. The location
where ``tt`` searches for it depends on the :ref:`launch mode <tt-config_modes>`.
You can also pass the configuration file explicitly in the ``--cfg``
:doc:`argument <arguments>`.

The ``tt`` configuration file is a YAML file with the following content:

.. code:: yaml

tt:
modules:
directory: path/to/modules/dir
app:
instances_available: path/to/available/applications
run_dir: path/to/run_dir
log_dir: path/to/log_dir
log_maxsize: num (MB)
log_maxage: num (days)
log_maxbackups: num
restart_on_failure: bool

modules section
~~~~~~~~~~~~~~~

* ``directory`` -- the directory where external modules are stored.
.. // TODO: add link to external modules doc page when it's ready

app section
~~~~~~~~~~~

* ``instances_available`` -- the directory where :ref:`instances <admin-instance_file>`
are stored.
* ``run_dir``-- the directory for instance runtime artifacts, such as console
sockets or PID files.
* ``log_dir`` -- the directory where log files are stored.
* ``log_maxsize`` -- the maximum size of the log file before it gets rotated,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tip: make sure to cross-link to the logrotate page from here, once it is created.

in megabytes. Default: 100.
* ``log_maxage`` -- the maximum age of log files in days. The age of a log
file is defined by the timestamp encoded in its name. Default: not defined
(log files aren't deleted based on their age).

.. note::

A day is defined as exactly 24 hours. It may not exactly correspond to
calendar days due to daylight savings, leap seconds, and other time adjustments.

* ``log_maxbackups`` -- the maximum number of stored log files.
Default: not defined (log files aren't deleted based on their count).
* ``restart_on_failure`` -- restart the instance on failure: ``true`` or ``false``.
Default: ``false``.

.. _tt-config_modes:

Launch modes
------------

``tt`` launch mode defines its working directory and the way it searches for the
configuration file. There are three launch modes:

* default
* system
* local

Default launch
~~~~~~~~~~~~~~

**Argument**: none

**Configuration file**: searched from the current directory to the root.
Taken from ``/etc/tarantool`` if the file is not found.

**Working directory**: The directory where the configuration file is found.

.. _tt-config_modes-system:

System launch
~~~~~~~~~~~~~

**Argument**: ``--system`` or ``-S``

**Configuration file**: Taken from ``/etc/tarantool``.

**Working directory**: Current directory.

.. _tt-config_modes-local:

Local launch
~~~~~~~~~~~~

**Argument**: ``--local=DIRECTORY`` or ``-L=DIRECTORY``

**Configuration file**: Searched from the specified directory to the root.
Taken from ``/etc/tarantool`` if the file is not found.

**Working directory**: The specified directory. If ``tarantool`` or ``tt``
executable files are found in the working directory, they will be used.
28 changes: 28 additions & 0 deletions doc/reference/tt_cli/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
tt CLI utility
==============

``tt`` is a utility that provides a unified command-line interface for managing
Tarantool-based applications. It covers a wide range of tasks -- from installing
a specific Tarantool version to managing remote instances and developing applications.

A multi-purpose tool for working with Tarantool from the command line, ``tt`` is
a potential replacement for :doc:`tarantoolctl </reference/tarantoolctl>`
and :doc:`Cartridge CLI </book/cartridge/cartridge_cli/index>`.

.. warning::

As of Tarantool 2.10, ``tt`` is in the early development stage. It includes
only basic functionality and may be unstable. We don't recommend using it
in production environments. Check out the list of :doc:`supported commands <commands>`.

To use ``tt``, you need to build it from sources.
See :doc:`Installation <installation>` for details.

.. toctree::

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I don't understand what it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a doc engine command to generate the table of contents – the list of pages inside the tt section.

:maxdepth: 1
:numbered: 0

installation
configuration
arguments
commands
36 changes: 36 additions & 0 deletions doc/reference/tt_cli/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Installation
============

To install the ``tt`` command-line utility:

1. Install third-party software required for building ``tt``:

* `git <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`__,
the version control system.
* `Go language <https://golang.org/doc/install>`__, version 1.18 or later.
* `mage <https://magefile.org/>`__ build tool.

2. Clone the `tarantool/tt <https://github.com/tarantool/tt>`_ repository:

.. code-block:: bash

git clone https://github.com/tarantool/tt --recursive

3. Go to the ``tt/`` directory and build ``tt`` using mage:

.. code-block:: bash

cd tt
mage build

``tt`` will appear in the current directory.

Enabling shell completion
-------------------------

To enable the completion for ``tt`` commands, run the following command specifying
the shell (``bash`` or ``zsh``):

.. code-block:: bash

. <(tt completion bash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why parentheses?