dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.49k stars 663 forks source link

set column max_width #992

Open potoo0 opened 3 years ago

potoo0 commented 3 years ago

Is it possible to support setting maximum width for column?

example: org result:

+----+-------+---------------------+---------------------+---------+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | job_name | start_time          | end_time            | elapsed | status | details                                                                                                                                                           

      |
+----+-------+---------------------+---------------------+---------+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 9  | test01   | 2021-04-22 17:16:30 | 2021-04-22 17:16:30 | 0s      | failed | 2021-04-22 17:16:30,320 - test01 - e:\algo_factory\logtodb\test.py[line:23]-WARNING: msg1\n2021-04-22 17:16:30,321 - test01 - e:\algo_factory\logtodb\test.py[line:24]-WARNING: msg2\n2021-04-22 17:16:30,321 - test01 - e:\algo_factory\logtodb\test.py[line:28]-ERROR: 1 / 0\nTraceback (most recent call last):\n  File "e:\algo_factory\logtodb\test.py", line 26, in main\n    1 / 0\nZeroDivisionError: division by zero\n |
| 10 | test02   | 2021-04-22 17:16:55 | 2021-04-22 17:16:55 | 2s      | failed | 2021-04-22 17:16:54,827 - test02 - e:\algo_factory\logtodb\test.py[line:23]-WARNING: msg1\n2021-04-22 17:16:54,827 - test02 - e:\algo_factory\logtodb\test.py[line:24]-WARNING: msg2\n2021-04-22 17:16:54,828 - test02 - e:\algo_factory\logtodb\test.py[line:28]-ERROR: 1 / 0\nTraceback (most recent call last):\n  File "e:\algo_factory\logtodb\test.py", line 26, in main\n    1 / 0\nZeroDivisionError: division by zero\n |
+----+-------+---------------------+---------------------+---------+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Expect the output after setting max_width=19:

+----+-------+---------------------+---------------------+---------+--------+---------------------+
| id | job_name | start_time          | end_time            | elapsed | status | details    |
+----+-------+---------------------+---------------------+---------+--------+---------------------+
| 9  | test01   | 2021-04-22 17:16:30 | 2021-04-22 17:16:30 | 0s      | failed | 2021-04-22 17:16... |
| 10 | test02   | 2021-04-22 17:16:55 | 2021-04-22 17:16:55 | 2s      | failed | 2021-04-22 17:16... |
+----+-------+---------------------+---------------------+---------+--------+---------------------+