Name | Type | Required | Default | Hint |
data | string | true | JSON serialized query, array of structs, or array of arrays to represent in table form | |
includedHeaders | string | false | A list of headers to include. | |
headerNames | string | false | An list/array of column headers to use instead of the default specifically for array of arrays | |
debug | boolean | false | false | Only print out the names of the columns and the first row values |
width | string | false | -1 | Override the terminal width |
Prints an ASCII table to the console based on incoming JSON. Input will be marshalled to be tabular if needed.
JSON data can be passed in the first param or piped into the command:
printTable [1,2,3]The following types of data are supported, passed as JSON.
package show | printTable
cat myfile.json | printTable
printTable {'a':2,'b':4}If an array is passed, each item in the array will become a row in the table.
╔═══╤═══╗
║ a │ b ║
╠═══╪═══╣
║ 2 │ 4 ║
╚═══╧═══╝
printTable data=[1,2,3] headerNames=numRepresent 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.
╔═════╗
║ num ║
╠═════╣
║ 1 ║
╟─────╢
║ 2 ║
╟─────╢
║ 3 ║
╚═════╝
printTable [{a:1,b:2},{a:3,b:4},{a:5,b:6}]For array of structs or serialized queries, if a list of columns is given that will be all that is displayed
╔═══╤═══╗
║ 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 ║
╚═══════╧═══════╝
#extensionlist | printTable name,versionThe "headerNames" argument allows you to overwrite auto created column names specifically for array of arrays
╔══════════════════════╤═══════════════════╗
║ name │ version ║
╠══════════════════════╪═══════════════════╣
║ MySQL │ 8.0.19 ║
╟──────────────────────┼───────────────────╢
║ Microsoft SQL Server │ 4.0.2206.100 ║
╟──────────────────────┼───────────────────╢
║ Ajax Extension │ 1.0.0.3 ║
╚══════════════════════╧═══════════════════╝
printTable data=[[1,2],[3,4],[5,6]] headerNames=name,versionThe "columnsOnly" parameter will give you a list of available columns and the first row of data to help you choose the columns you want
╔════════╤═══════════╗
║ name │ version ║
╠════════╪═══════════╣
║ 1 │ 2 ║
╟────────┼───────────╢
║ 3 │ 4 ║
╟────────┼───────────╢
║ 5 │ 6 ║
╚════════╧═══════════╝
printTable "[{'a':2},{'a':4},{'a':5},{'a':8}]" --debug
╔════════╤════════════════╗
║ Column │ First Row Data ║
╠════════╪════════════════╣
║ a │ 2 ║
╚════════╧════════════════╝