-
Notifications
You must be signed in to change notification settings - Fork 12
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
connect: expanded formatting modes #535
Conversation
e1e2335
to
e38eca8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion with @LeonidVas and @psergee we decided that an import of the go-pretty
code should be done in a different way:
- Create a patch for the latest release of the
go-pretty
. The patch should be as small as possible. - Add
go-pretty
as a git submodule. - Patch the submodule with the patch on the build step.
See how it is already done with cartridge-cli in the repo.
68a7c8e
to
2a0519c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update, I have a couple of questions about the go-pretty
patching.
cli/formatter/go-pretty/extra/001_add_transposing_and_colconf.patch
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by mistake.
2f62466
to
cef8fdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad to see that we could resume without the go-pretty
patching. Let's now focus on code style.
cef8fdc
to
104246c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more questions.
But it covered by integration tests, why duplicate? |
104246c
to
a4647e8
Compare
f79de6e
to
52e35ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The critical lack of the implementation is the input data for the MakeOutput
function inconsistent with all formats.
{ // Ok.
formatter.DefaultFormat,
"---\n- 1\n- 2\n- 3\n...",
"---\n- 1\n- 2\n- 3\n...\n",
false,
},
{ // Ok.
formatter.TableFormat,
"---\n- 1\n- 2\n- 3\n...",
"+------+\n" +
"| col1 |\n" +
"+------+\n" +
"| 1 |\n" +
"+------+\n" +
"| 2 |\n" +
"+------+\n" +
"| 3 |\n" +
"+------+\n",
false,
},
{ // The problem. It does not print a tuple.
formatter.DefaultFormat,
"---\n- DATA: 8\n COLUMN_1: 30\n FOO: 1\n COLUMN_2: 50\n...",
"---\n- DATA: 8\n COLUMN_1: 30\n FOO: 1\n COLUMN_2: 50\n...\n",
false,
},
{ // Ok.
formatter.TableFormat,
"---\n- DATA: 8\n COLUMN_1: 30\n FOO: 1\n COLUMN_2: 50\n...\n",
"+----------+----------+------+-----+\n" +
"| COLUMN_1 | COLUMN_2 | DATA | FOO |\n" +
"+----------+----------+------+-----+\n" +
"| 30 | 50 | 8 | 1 |\n" +
"+----------+----------+------+-----+\n",
false,
},
As a user, I expect to pass a valid data to it, I will get a valid result as tuples for all formats. But in practice, not all formats can work with the same input data. As example, DefaultFormat
/YamlFormat
could not work with a data with fields names as expected (return tuples without field names in the format).
This will overсomplicate development in the future. We will need to build two different YAML documents for export tuples from IPROTO.
So we need to make sure that the same valid input is valid for all formats, and formatted correctly by them.
08782df
to
451fe0c
Compare
451fe0c
to
f3d4709
Compare
I did a little code refactoring (but not tests refactoring). I suggest to forget about everything that happened before and start the review all over again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! I've got some questions, please see the comments below.
Also, are changes from x = x + ...
to x += ...
and x++
considered as too sinister nits? I just think that it would be nice to see a uniform code style (and the method of addition differs from line to line).
f3d4709
to
c2295db
Compare
The patch adds a `\help` command to the `tt connect` commands. It also improves an internal logic of the command processing. Part of #162
The command already exists in the Tarantool console, but it requires execute right to be executed. We add the same command to `tt` and now everebody could leave `tt connect` console without errors. Part of #162
c2295db
to
c140f0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM =)
c140f0b
to
d9731de
Compare
The patch introduces formatting modes for the interactive console [1]. 1. https://www.notion.so/tarantool/TT-connect-table-output-format-like-fselect-70bd44d1f77b40cf87eddb357adaf37a Closes #162 @TarantoolBot document Title: Expanded formatting modes The patchset introduces addition commands for the `tt connect` console. It adds several common commands that relate to a general functionality: * `\help`, `?` - to show help message with additional information and a list of all commands. * `\quit`, `\q` - quit from the console. Previously this command worked on the `tarantool` side, but now it works on the `tt` side and does not require execution rights for a user. In addition, the patch adds commands for extended output modes: * `\set output <format>` - set format lua, table, ttable or yaml (default) * `\set table_format <format>` - set table format default, jira or markdown * `\set graphics <false/true>` - disables/enables (default) pseudographics for table modes * `\set table_column_width <width>` - set max column width for table/ttable * `\xw <width>` - set max column width for table/ttable * `\x` - switches output format cyclically * `\x[l,t,T,y]` - set output format lua, table, ttable or yaml * `\x[g,G]` - disables/enables pseudographics for table modes Supported formats: 1. `yaml` - shows data as a YAML document. The format is used now by `tarantool` and `tt`. 2. `lua` - shows data as Lua-compatible structs. 3. `table` - shows data as a pseudo graphical table. 4. `ttable` - the same as the table format, but a result table is transposed (rotate data from rows to columns). Supported table formats (for `table` or `ttable` formats): 1. `default` - shows data as a pseudo graphical table. 2. `markdown` - shows data as a Markdown-compatible table. 3. `jira` - shows data as a Jira-compatible table. Example: ``` > \set output table > box.space.customers:select() +------+-----------+------+ | col1 | col2 | col3 | +------+-----------+------+ | 1 | Elizabeth | 12 | +------+-----------+------+ > \xg > box.space.customers:select() col1 col2 col3 1 Elizabeth 12 2 Mary 46 3 David 33 ```
The patch introduces formatting modes for the interactive console [1].
Closes #162
@TarantoolBot document
Title: Expanded formatting modes
The patchset introduces addition commands for the
tt connect
console.It adds several common commands that relate to a general functionality:
\help
,?
- to show help message with additional information and a list of all commands.\quit
,\q
- quit from the console. Previously this command worked on thetarantool
side, but now it works on thett
side and does not require execution rights for a user.In addition, the patch adds commands for extended output modes:
\set output <format>
- set format lua, table, ttable or yaml (default)\set table_format <format>
- set table format default, jira or markdown\set graphics <false/true>
- disables/enables (default) pseudographics for table modes\set table_column_width <width>
- set max column width for table/ttable\xw <width>
- set max column width for table/ttable\x
- switches output format cyclically\x[l,t,T,y]
- set output format lua, table, ttable or yaml\x[g,G]
- disables/enables pseudographics for table modesSupported formats:
yaml
- shows data as a YAML document. The format is used now bytarantool
andtt
.lua
- shows data as Lua-compatible structs.table
- shows data as a pseudo graphical table.ttable
- the same as the table format, but a result table is transposed (rotate data from rows to columns).Supported table formats (for
table
orttable
formats):default
- shows data as a pseudo graphical table.markdown
- shows data as a Markdown-compatible table.jira
- shows data as a Jira-compatible table.Example: