Bug #116573 Allow plugins to do formatting of output in MySQL Shell
Submitted: 6 Nov 22:52 Modified: 7 Nov 6:29
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Shell General / Core Client Severity:S4 (Feature request)
Version:9.1.0 OS:Any
Assigned to: CPU Architecture:Any

[6 Nov 22:52] Daniël van Eeden
Description:
MySQL Shell is already more extensible than the MySQL Client. This proposal would add another extension point.

Allow a plugin to define a formatter. This formatter should be initialized with column metadata and then be called to draw the table header and again for every row of the table.

This would make it possible to define formatters that do the following:
- Use unicode line drawing characters to draw the table similar to what is described in Bug #77279
- Use terminal escape codes to print the header in bold.
- Print the JSON contents of a cell with pretty printing like JSON_PRETTY() but possibly with syntax highlighting added to that.
- Print the output of SHOW CREATE VIEW and others with a SQL formatter and/or syntax highlighter
- Use Sixel to print images and other graphics
- Add custom links (e.g. a "isbn" column with only the ISBN number as value, but printed as https://isbnsearch.org/isbn/9783161484100 )
- Wide columns printed over multiple lines
- XML, HTML, CSV, JSON, etc as output

Some of this is similar to how a pager can be used but a pager has very limited information to work with.
- 

How to repeat:
See description
[6 Nov 22:53] Daniël van Eeden
Example for how this could work

Attachment: mysqlsh-format-demo.py (text/x-python), 2.73 KiB.

[7 Nov 6:29] MySQL Verification Team
Hello Daniël,

Thank you for the reasonable feature request!

regards,
Umesh