Pular para o conteúdo principal
Versão: 0.1.0-alpha.3

Format e Style

Componentes de formatação e estilização de texto para saída de terminal bonita.

Format

Formatar e renderizar texto como markdown, código, emoji ou templates.

Uso Básico

echo "# Hello World" | invowk tui format --type markdown

Opções

OpçãoDescrição
--typeTipo de formato: markdown, code, emoji, template
--languageLinguagem para highlight de código
--themeTema do Glamour para highlight de código

Markdown

Renderizar markdown com cores e formatação:

# From stdin
echo "# Heading\n\nSome **bold** and *italic* text" | invowk tui format --type markdown

# From file
cat README.md | invowk tui format --type markdown

Highlight de Código

Highlight de sintaxe de código:

# Specify language
cat main.go | invowk tui format --type code --language go

# Python
cat script.py | invowk tui format --type code --language python

# JavaScript
cat app.js | invowk tui format --type code --language javascript

Conversão de Emoji

Converter shortcodes de emoji para emojis reais:

echo "Hello :wave: World :smile:" | invowk tui format --type emoji
# Output: Hello 👋 World 😄

Exemplos do Mundo Real

Exibir README

cat README.md | invowk tui format --type markdown

Mostrar Diff de Código

git diff | invowk tui format --type code --language diff

Mensagem de Boas-vindas

echo ":rocket: Welcome to MyApp :sparkles:" | invowk tui format --type emoji

Style

Aplicar estilização de terminal ao texto.

Uso Básico

invowk tui style --foreground "#FF0000" "Red text"

Opções

OpçãoDescrição
--foregroundCor do texto (hex ou nome)
--backgroundCor de fundo
--boldTexto em negrito
--italicTexto em itálico
--underlineTexto sublinhado
--strikethroughTexto tachado
--faintTexto esmaecido
--blinkTexto piscando
--reverseInverter cores
--borderEstilo de borda
--padding-*Padding (left, right, top, bottom)
--margin-*Margin (left, right, top, bottom)
--widthLargura fixa
--heightAltura fixa
--alignAlinhamento de texto: left, center, right

Cores

Use cores hex ou nomes:

# Hex colors
invowk tui style --foreground "#FF0000" "Red"
invowk tui style --foreground "#00FF00" "Green"
invowk tui style --foreground "#0000FF" "Blue"

# With background
invowk tui style --foreground "#FFFFFF" --background "#FF0000" "White on Red"

Decorações de Texto

# Bold
invowk tui style --bold "Bold text"

# Italic
invowk tui style --italic "Italic text"

# Combined
invowk tui style --bold --italic --underline "All decorations"

# Dimmed
invowk tui style --faint "Subtle text"

Piping

Estilizar texto de stdin:

echo "Important message" | invowk tui style --bold --foreground "#FF0000"

Bordas

Adicionar bordas ao redor do texto:

# Simple border
invowk tui style --border normal "Boxed text"

# Rounded border
invowk tui style --border rounded "Rounded box"

# Double border
invowk tui style --border double "Double border"

# With padding
invowk tui style --border rounded --padding-left 2 --padding-right 2 "Padded"

Estilos de borda: normal, rounded, double, thick, hidden

Layout

# Fixed width
invowk tui style --width 40 --align center "Centered"

# With margins
invowk tui style --margin-left 4 "Indented text"

# Box with all options
invowk tui style \
--border rounded \
--foreground "#FFFFFF" \
--background "#333333" \
--padding-left 2 \
--padding-right 2 \
--width 50 \
--align center \
"Styled Box"

Exemplos do Mundo Real

Mensagens de Sucesso/Erro

# Success
echo "Build successful!" | invowk tui style --foreground "#00FF00" --bold

# Error
echo "Build failed!" | invowk tui style --foreground "#FF0000" --bold

# Warning
echo "Deprecated feature" | invowk tui style --foreground "#FFA500" --italic

Cabeçalhos e Seções

# Main header
invowk tui style --bold --foreground "#00BFFF" "=== Project Setup ==="
echo ""

# Subheader
invowk tui style --foreground "#888888" "Configuration Options:"

Caixas de Status

# Info box
invowk tui style \
--border rounded \
--foreground "#FFFFFF" \
--background "#0066CC" \
--padding-left 1 \
--padding-right 1 \
"Info: Server is running on port 3000"

# Warning box
invowk tui style \
--border rounded \
--foreground "#000000" \
--background "#FFCC00" \
--padding-left 1 \
--padding-right 1 \
"Warning: API key will expire soon"

Em Scripts

{
name: "status"
description: "Show system status"
implementations: [{
script: """
invowk tui style --bold --foreground "#00BFFF" "System Status"
echo ""

# Check services
if systemctl is-active nginx > /dev/null 2>&1; then
echo "nginx: " | tr -d '\n'
invowk tui style --foreground "#00FF00" "running"
else
echo "nginx: " | tr -d '\n'
invowk tui style --foreground "#FF0000" "stopped"
fi

if systemctl is-active postgresql > /dev/null 2>&1; then
echo "postgres: " | tr -d '\n'
invowk tui style --foreground "#00FF00" "running"
else
echo "postgres: " | tr -d '\n'
invowk tui style --foreground "#FF0000" "stopped"
fi
"""
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Padrões Combinados

Saída Formatada

# Header
invowk tui style --bold --foreground "#FFD700" "Package Info"
echo ""

# Render package description as markdown
cat package.md | invowk tui format --type markdown

Interativo com Saída Estilizada

NAME=$(invowk tui input --title "Project name:")

if invowk tui confirm "Create $NAME?"; then
invowk tui spin --title "Creating..." -- mkdir -p "$NAME"
echo ""
invowk tui style --foreground "#00FF00" --bold "Created $NAME successfully!"
else
invowk tui style --foreground "#FF0000" "Cancelled"
fi

Próximos Passos