mirror of
https://github.com/charmbracelet/gum
synced 2024-06-07 00:02:35 +02:00
feat: gum style
can take multiple arguments
This commit is contained in:
parent
e2854d5b23
commit
25a12fbbc6
|
@ -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 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 \
|
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."
|
||||||
|
|
3
main.go
3
main.go
|
@ -26,7 +26,8 @@ func main() {
|
||||||
case "spin <command>":
|
case "spin <command>":
|
||||||
pop.Spin.Run()
|
pop.Spin.Run()
|
||||||
case "style":
|
case "style":
|
||||||
pop.Style.Text, _ = stdin.Read()
|
input, _ := stdin.Read()
|
||||||
|
pop.Style.Text = []string{input}
|
||||||
pop.Style.Run()
|
pop.Style.Run()
|
||||||
case "style <text>":
|
case "style <text>":
|
||||||
pop.Style.Run()
|
pop.Style.Run()
|
||||||
|
|
|
@ -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))
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@ package style
|
||||||
|
|
||||||
// Options is the customization options for the style command.
|
// Options is the customization options for the style command.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Text string `arg:"" optional:"" help:"Text to style"`
|
Text []string `arg:"" optional:"" help:"Text to style"`
|
||||||
|
|
||||||
Background string `help:"Background color"`
|
Background string `help:"Background color"`
|
||||||
Foreground string `help:"Foreground color"`
|
Foreground string `help:"Foreground color"`
|
||||||
|
|
|
@ -1 +1,31 @@
|
||||||
package style
|
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))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue