feat: gum style can take multiple arguments

This commit is contained in:
Maas Lalani 2022-07-06 13:54:32 -04:00
parent e2854d5b23
commit 25a12fbbc6
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
5 changed files with 35 additions and 31 deletions

View file

@ -36,4 +36,5 @@ echo "One sec, while I finish my drink."
pop spin --title "Drinking some $POP soda pop..." --color 212 -- sleep 5
pop style --width 50 --padding "1 5" --margin "1 2" --border double --border-foreground 212 \
"Well, it was nice meeting you, $(pop style --foreground 212 "$NAME"). Hope to see you soon! Don't forget to drink some $(pop style --foreground 212 $POP) soda pop."
"Well, it was nice meeting you, $(pop style --foreground 212 "$NAME"). Hope to see you soon!"\
"Don't forget to drink some $(pop style --foreground 212 $POP) soda pop."

View file

@ -26,7 +26,8 @@ func main() {
case "spin <command>":
pop.Spin.Run()
case "style":
pop.Style.Text, _ = stdin.Read()
input, _ := stdin.Read()
pop.Style.Text = []string{input}
pop.Style.Run()
case "style <text>":
pop.Style.Run()

View file

@ -1,28 +0,0 @@
package style
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
// Run provides a shell script interface for the Lip Gloss styling.
// https://github.com/charmbracelet/lipgloss
func (o Options) Run() {
fmt.Println(lipgloss.NewStyle().
Foreground(lipgloss.Color(o.Foreground)).
Background(lipgloss.Color(o.Background)).
BorderBackground(lipgloss.Color(o.BorderBackground)).
BorderForeground(lipgloss.Color(o.BorderForeground)).
Align(align[o.Align]).
Bold(o.Bold).
Border(border[o.Border]).
Margin(parseMargin(o.Margin)).
Padding(parsePadding(o.Padding)).
Height(o.Height).
Width(o.Width).
Faint(o.Faint).
Italic(o.Italic).
Strikethrough(o.Strikethrough).
Render(o.Text))
}

View file

@ -2,7 +2,7 @@ package style
// Options is the customization options for the style command.
type Options struct {
Text string `arg:"" optional:"" help:"Text to style"`
Text []string `arg:"" optional:"" help:"Text to style"`
Background string `help:"Background color"`
Foreground string `help:"Foreground color"`

View file

@ -1 +1,31 @@
package style
import (
"fmt"
"strings"
"github.com/charmbracelet/lipgloss"
)
// Run provides a shell script interface for the Lip Gloss styling.
// https://github.com/charmbracelet/lipgloss
func (o Options) Run() {
text := strings.Join(o.Text, " ")
fmt.Println(lipgloss.NewStyle().
Foreground(lipgloss.Color(o.Foreground)).
Background(lipgloss.Color(o.Background)).
BorderBackground(lipgloss.Color(o.BorderBackground)).
BorderForeground(lipgloss.Color(o.BorderForeground)).
Align(align[o.Align]).
Bold(o.Bold).
Border(border[o.Border]).
Margin(parseMargin(o.Margin)).
Padding(parsePadding(o.Padding)).
Height(o.Height).
Width(o.Width).
Faint(o.Faint).
Italic(o.Italic).
Strikethrough(o.Strikethrough).
Render(text))
}