Skip to main content
Version: 0.1.0-alpha.1

Input and Write

Text entry components for gathering user input.

Input

Single-line text input with optional validation.

Basic Usage

invowk tui input --title "What is your name?"

Options

OptionDescription
--titlePrompt text
--descriptionDescription below the title
--placeholderPlaceholder text
--valueInitial value
--passwordHide input (for secrets)
--char-limitMaximum characters
--widthInput field width
--promptPrompt character(s) before input

Examples

# With placeholder
invowk tui input --title "Email" --placeholder "user@example.com"

# Password input (hidden)
invowk tui input --title "Password" --password

# With initial value
invowk tui input --title "Name" --value "John Doe"

# Limited length
invowk tui input --title "Username" --char-limit 20

Capturing Output

NAME=$(invowk tui input --title "Enter your name:")
echo "Hello, $NAME!"

In Scripts

{
name: "create-user"
implementations: [{
script: """
USERNAME=$(invowk tui input --title "Username:" --char-limit 20)
EMAIL=$(invowk tui input --title "Email:" --placeholder "user@example.com")
PASSWORD=$(invowk tui input --title "Password:" --password)

echo "Creating user: $USERNAME ($EMAIL)"
./scripts/create-user.sh "$USERNAME" "$EMAIL" "$PASSWORD"
"""
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Write

Multi-line text editor for longer input like descriptions or commit messages.

Basic Usage

invowk tui write --title "Enter description"

Options

OptionDescription
--titleEditor title
--descriptionDescription below the title
--placeholderPlaceholder text
--valueInitial content
--show-line-numbersDisplay line numbers
--char-limitMaximum characters
--widthEditor width
--heightEditor height

Examples

# Basic editor
invowk tui write --title "Description:"

# With line numbers
invowk tui write --title "Code:" --show-line-numbers

# With initial content
invowk tui write --title "Edit message:" --value "Initial text here"

Use Cases

Git Commit Message

MESSAGE=$(invowk tui write --title "Commit message:")
git commit -m "$MESSAGE"

Multi-Line Configuration

CONFIG=$(invowk tui write --title "Enter YAML config:" --show-line-numbers)
echo "$CONFIG" > config.yaml

Release Notes

NOTES=$(invowk tui write --title "Release notes:")
gh release create v1.0.0 --notes "$NOTES"

In Scripts

{
name: "commit"
description: "Interactive commit with editor"
implementations: [{
script: """
# Show staged changes
git diff --cached --stat

# Get commit message
MESSAGE=$(invowk tui write --title "Commit message:")

if [ -z "$MESSAGE" ]; then
echo "Commit cancelled (empty message)"
exit 1
fi

git commit -m "$MESSAGE"
"""
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Tips

Handling Empty Input

NAME=$(invowk tui input --title "Name:")
if [ -z "$NAME" ]; then
echo "Name is required!"
exit 1
fi

Validation Loop

while true; do
EMAIL=$(invowk tui input --title "Email:")
if echo "$EMAIL" | grep -qE '^[^@]+@[^@]+\.[^@]+$'; then
break
fi
echo "Invalid email format, try again."
done

Default Values

# Use shell default if empty
NAME=$(invowk tui input --title "Name:" --placeholder "Anonymous")
NAME="${NAME:-Anonymous}"

Next Steps