-
Notifications
You must be signed in to change notification settings - Fork 185
2a. Terminal View
Kui Provides a fully-featured terminal. In response to certain commands, Kui augments the basic ASCII art presented by those commands with graphics.
The UI of Terminal is divided into Command Blocks
. Each of the Command Block contains Command Input
and Output
.
If your command handler returns one the following data types, it will be rendered in the Kui Terminal view: string
, boolean
, and Table
. More complex data types can be presented in custom views. For example, Kui includes a Sidecar view component, some examples of which are shown on the top page. This page focuses on command handlers that are intended to be presented in the Terminal.
export const printString = () => 'Hello!'
export const printOK = () => true
To render a table in terminal, your command handler will return a Table model. Kui then visualizes the table for you using a built-in view. This built-in view uses the Carbon Components library. Here's an example of returning a 2x2 Table:
import { Table } from '@kui-shell/core'
// shown in image labed B
export const printTable = (): Table => ({
header: { name: 'Column1', attributes: [{ value: 'Column2' }]},
body: [
{ name: 'Row1Column1', attributes: [{ value: 'Row1Column2' }]},
{ name: 'Row2Column1', attributes: [{ value: 'Row2Column2' }]}
]
})
In this example code, printString
, printOK
and printTable
are Kui Command Handlers that happen to take no arguments. For more information on Command Handlers, how they can consume required and optional parameters, and how to link your handler to a particular command-line string, consult the Kui Command Documentation.