2022-07-13 15:55:36 +02:00
|
|
|
// Package join provides a shell script interface for the lipgloss
|
|
|
|
// JoinHorizontal and JoinVertical commands. It allows you to join multi-line
|
|
|
|
// text to build different layouts.
|
|
|
|
//
|
|
|
|
// For example, you can place two bordered boxes next to each other: Note: We
|
|
|
|
// wrap the variable in quotes to ensure the new lines are part of a single
|
|
|
|
// argument. Otherwise, the command won't work as expected.
|
|
|
|
//
|
2022-08-05 00:45:19 +02:00
|
|
|
// $ gum join --horizontal "$BUBBLE_BOX" "$GUM_BOX"
|
2022-07-13 15:55:36 +02:00
|
|
|
//
|
2022-08-05 00:45:19 +02:00
|
|
|
// ╔══════════════════════╗╔═════════════╗
|
|
|
|
// ║ ║║ ║
|
|
|
|
// ║ Bubble ║║ Gum ║
|
|
|
|
// ║ ║║ ║
|
|
|
|
// ╚══════════════════════╝╚═════════════╝
|
2022-07-08 01:28:44 +02:00
|
|
|
package join
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
2022-08-05 00:45:19 +02:00
|
|
|
|
|
|
|
"github.com/charmbracelet/gum/internal/decode"
|
2022-07-08 01:28:44 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Run is the command-line interface for the joining strings through lipgloss.
|
2022-07-13 04:12:02 +02:00
|
|
|
func (o Options) Run() error {
|
2022-07-08 01:28:44 +02:00
|
|
|
join := lipgloss.JoinHorizontal
|
|
|
|
if o.Vertical {
|
|
|
|
join = lipgloss.JoinVertical
|
|
|
|
}
|
|
|
|
fmt.Println(join(decode.Align[o.Align], o.Text...))
|
2022-07-13 04:12:02 +02:00
|
|
|
return nil
|
2022-07-08 01:28:44 +02:00
|
|
|
}
|