Skip to main content
Version: 0.20.0

Table and Spin

Data display and loading indicator components.

Table​

Display and optionally select from tabular data.

Basic Usage​

# From a CSV file
invowk tui table --file data.csv

# From stdin with separator
echo -e "name|age|city
Alice|30|NYC
Bob|25|LA" | invowk tui table --separator "|"

Options​

OptionDescription
--fileCSV file to display
--separatorColumn separator (default: ,)
--columnsColumn headers (override file header)
--widthsColumn widths (comma-separated integers)
--selectableAllow row selection
--heightTable height

Examples​

# Display CSV
invowk tui table --file users.csv

# Custom separator (TSV)
invowk tui table --file data.tsv --separator $' '

# Pipe-separated
cat data.txt | invowk tui table --separator "|"

Redirected Output​

When stdout is not a terminal, a table without --selectable does not open. It prints the rows as plain text and exits 0, with or without a terminal:

$ printf 'name|age|city\nAlice|30|NYC\nBob|25|LA\n' | invowk tui table --separator '|' | cat
name age city
Alice 30 NYC
Bob 25 LA

The first line holds the column titles (the header row or --columns), then one line per row. Cells are left-aligned and padded to the widest cell of their column, columns are separated by two spaces, and there is no border and no color. A newline, tab or other control character in a cell is printed as a space, and so is a format character (such as a bidirectional override or a zero-width space) and the line or paragraph separator U+2028 or U+2029, so each row stays on one line and reads in the order it is stored. A byte sequence that is not valid UTF-8 is printed as U+FFFD (�). Every row is printed: --height and --widths do not apply. A selectable table still draws on the terminal, so row=$(invowk tui table --selectable ...) works as before.

Selectable Tables​

# Select a row
SELECTED=$(invowk tui table --file servers.csv --selectable)
echo "Selected: $SELECTED"

The selected row is returned as the full CSV line.

Real-World Examples​

Display Server List​

# servers.csv:
# name,ip,status
# web-1,10.0.0.1,running
# web-2,10.0.0.2,running
# db-1,10.0.0.3,stopped

invowk tui table --file servers.csv

Select and SSH​

# Select a server
SERVER=$(cat servers.csv | invowk tui table --selectable | cut -d',' -f2)
ssh "user@$SERVER"

Process List​

ps aux --no-headers | awk '{print $1","$2","$11}' |
(echo "USER,PID,COMMAND"; cat) |
invowk tui table --selectable

Spin​

Show a spinner while running a long command.

Basic Usage​

invowk tui spin --title "Installing..." -- npm install

Options​

OptionDescription
--titleSpinner title/message
--typeSpinner animation type

Spinner Types​

Available spinner animations:

  • line - Simple line
  • dot - Dots
  • minidot - Small dots
  • jump - Jumping dots
  • pulse - Pulsing dot
  • points - Points
  • globe - Spinning globe
  • moon - Moon phases
  • monkey - Monkey
  • meter - Progress meter
  • hamburger - Hamburger menu
  • ellipsis - Ellipsis
invowk tui spin --type globe --title "Downloading..." -- curl -O https://example.com/file
invowk tui spin --type moon --title "Building..." -- make build
invowk tui spin --type pulse --title "Testing..." -- npm test

Examples​

# Basic spinner
invowk tui spin --title "Building..." -- go build ./...

# With specific type
invowk tui spin --type dot --title "Installing dependencies..." -- npm install

# Long-running task
invowk tui spin --title "Compiling assets..." -- webpack --mode production

Chained Spinners​

echo "Step 1/3: Dependencies"
invowk tui spin --title "Installing..." -- npm install

echo "Step 2/3: Build"
invowk tui spin --title "Building..." -- npm run build

echo "Step 3/3: Tests"
invowk tui spin --title "Testing..." -- npm test

echo "Done!" | invowk tui style --foreground "#00FF00" --bold

Exit Code Handling​

The spin command returns the exit code of the wrapped command:

if invowk tui spin --title "Testing..." -- npm test; then
echo "Tests passed!"
else
echo "Tests failed!"
exit 1
fi

Other outcomes:

  • Ctrl+C. Pressing Ctrl+C while the spinner shows stops the wrapped command, prints the output it produced so far, and exits with status 1, the status any cancelled invowk command gives. Only the command spin started is stopped: processes that it started itself can keep running. On Windows, a command that is a .cmd or .bat script, such as npm, runs under cmd.exe, so only cmd.exe is stopped and the tool it started can keep running.
  • A command that does not stop. If the command has not ended 15 seconds after it was stopped, spin exits with status 1, prints nothing from it, and says on stderr that it may still be running.
  • A command killed by a signal. A command that ends without an exit status, because a signal killed it, makes spin print its output and exit with status 1.
  • A spinner failure. If the spinner cannot draw after the command started, the command keeps running. spin then prints its output and exits with its status, and the spinner error goes to stderr as a warning.

In Scripts​

{
name: "deploy"
description: "Deploy with progress indication"
implementations: [{
script: {content: """
echo "Deploying application..."

invowk tui spin --title "Building Docker image..." --
docker build -t myapp .

invowk tui spin --title "Pushing to registry..." --
docker push myapp

invowk tui spin --title "Updating Kubernetes..." --
kubectl rollout restart deployment/myapp

invowk tui spin --title "Waiting for rollout..." --
kubectl rollout status deployment/myapp

echo "Deployment complete!" | invowk tui style --foreground "#00FF00" --bold
"""}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Combined Patterns​

Select Then Execute with Spinner​

# Choose what to build
PROJECT=$(invowk tui choose --title "Build which project?" api web worker)

# Build with spinner
invowk tui spin --title "Building $PROJECT..." -- make "build-$PROJECT"

Table Selection with Spinner Action​

# Select server
SERVER=$(invowk tui table --file servers.csv --selectable | cut -d',' -f1)

# Restart with spinner
invowk tui spin --title "Restarting $SERVER..." -- ssh "$SERVER" "systemctl restart myapp"

Next Steps​