Fixed
Pinned fields
Click on the next to a field label to start pinning.
Details
Details
Sentry
Sentry
Created May 11, 2021 at 10:19 PM
Updated May 11, 2021 at 10:24 PM
Resolved May 11, 2021 at 10:24 PM
BoxLang: Our new JVM Dynamic Language made by Ortus! Check it out: https://www.boxlang.io
This command will be a CLI-based wrapper for the new table printer so devs can print nice ASCII art tables right from the command line by just passing in JSON in any format
query
array of arrays
array of structs
simple value (which will be converted to a single row/col)
The params will be:
data - JSON serialized query, array of structs, or array of arrays to represent in table form
includedHeaders - A list of headers to include. Used for query inputs
headerNames - An list/array of column headers to use instead of the default
debug - Only print out the names of the columns and the first row values
JSON data can be passed in the first param or piped into the command:
printTable [1,2,3] package show | printTable cat myfile.json | printTable
The following types of data are supported, passed as JSON.
If the object is a struct, a table with a single row will be printed, using the struct keys as the column names.
printTable {'a':2,'b':4} +-------+ ¦ a ¦ b ¦ ¦---+---¦ ¦ 2 ¦ 4 ¦ +-------+
If an array is passed, each item in the array will become a row in the table.
printTable data=[1,2,3] headerNames=num +-----+ ¦ num ¦ ¦-----¦ ¦ 1 ¦ ¦-----¦ ¦ 2 ¦ ¦-----¦ ¦ 3 ¦ +-----+
Represent tabular data as an array of arrays or an arary of structs. The number of columns will be based on the first row's data.
For array and simple values, the column names will default to: col_1, col_2, etc.
For arrays of structs, the struct keys in the first row will be used
. printTable [{a:1,b:2},{a:3,b:4},{a:5,b:6}] +-------+ ¦ a ¦ b ¦ ¦---+---¦ ¦ 1 ¦ 2 ¦ ¦---+---¦ ¦ 3 ¦ 4 ¦ ¦---+---¦ ¦ 5 ¦ 6 ¦ +-------+ printTable [[1,2],[3,4],[5,6]] +---------------+ ¦ col_1 ¦ col_2 ¦ ¦-------+-------¦ ¦ 1 ¦ 2 ¦ ¦-------+-------¦ ¦ 3 ¦ 4 ¦ ¦-------+-------¦ ¦ 5 ¦ 6 ¦ +---------------+
For array of structs or serialized queries, if a list of columns is given that will be all that is displayed
#extensionlist | printTable name,version +------------------------------------------+ ¦ name ¦ version ¦ ¦----------------------+-------------------¦ ¦ MySQL ¦ 8.0.19 ¦ ¦----------------------+-------------------¦ ¦ Microsoft SQL Server ¦ 4.0.2206.100 ¦ ¦----------------------+-------------------¦ ¦ Ajax Extension ¦ 1.0.0.3 ¦ +------------------------------------------+
The "headerNames" argument allows you to overwrite existing or auto created column names
printTable data=[[1,2],[3,4],[5,6]] headerNames=name,version +--------------------+ ¦ name ¦ version ¦ ¦--------+-----------¦ ¦ 1 ¦ 2 ¦ ¦--------+-----------¦ ¦ 3 ¦ 4 ¦ ¦--------+-----------¦ ¦ 5 ¦ 6 ¦ +--------------------+
The "columnsOnly" parameter will give you a list of available columns and the first row of data to help you choose the columns you want
printTable "[{'a':2},{'a':4},{'a':5},{'a':8}]" --debug +-------------------------+ ¦ Column ¦ First Row Data ¦ ¦--------+----------------¦ ¦ a ¦ 2 ¦ +-------------------------+