From 4557fe840691d7c8b244b8093e50de85aa66f920 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 7 Jul 2022 23:21:31 -0400 Subject: [PATCH] docs: `gum write`, `gum join` --- README.md | 56 ++++++++++++++++++++++++++++++++++++------------------- gum.go | 4 ++-- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8775701..59227ca 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # Gum -Tasty Bubble Gum for your shell. - -Gum is a command-line tool (`gum`) that gives you the power of +Gum is a collection of command-line utilities that make your shell scripts a +little more glamorous. It gives you the power of [Bubbles](https://github.com/charmbracelet/bubbles) and [Lip Gloss](https://github.com/charmbracelet/lipgloss) without needing to write any Go code. -The following example is generated entirely from a [single bash script](./examples/demo.sh). +The following example is running from a [single Bash script](./examples/demo.sh). Shell running the Gum examples/demo.sh script @@ -20,6 +19,14 @@ Prompt your users for input with a simple command. gum input > answer.text ``` +#### Write + +Prompt your users to write some multi-line text. + +```bash +gum write > story.text +``` + #### Search Allow your users to filter through a list of options by fuzzy searching. @@ -31,7 +38,7 @@ echo Cherry >> flavors.text cat flavors.text | gum search > selection.text ``` -#### Loading +#### Progress Display a progress bar while loading. The following command will display a progress bar and increment the progress by 10% every 1 second. Thus, taking 10 @@ -51,27 +58,20 @@ command exits. gum spin --spinner dot --title "Buying Bubble Gum..." -- sleep 5 ``` -``` -⣽ Buying Bubble Gum... -``` - - -## Styling +## Styling and Layout +#### Style Pretty print any string with any layout with one command. ```bash gum style \ --foreground "#FF06B7" --border "double" --align "center" \ - --width 50 --margin 2 --padding "2 4" \ + --width 50 --margin "1 2" --padding "2 4" \ "Bubble Gum (1¢)" "So sweet and so fresh\!" ``` - -Result: ``` - ╔══════════════════════════════════════════════════╗ ║ ║ ║ ║ @@ -80,10 +80,30 @@ Result: ║ ║ ║ ║ ╚══════════════════════════════════════════════════╝ - - + ``` +#### Join + +Combine text vertically or horizontally with a single command, use this command +with `gum style` to build layouts and pretty output. + +Note: It's important to wrap the output of `gum style` in quotes to ensure new +lines (`\n`) are part of a single argument passed to the `join` command. + +```bash +gum join "$(gum style --padding "1 5" --border double "I love Bubble Gum")" "$(gum style --padding "1 5" --border double "<3")" +``` + +``` +╔═══════════════════════════╗╔════════════╗ +║ ║║ ║ +║ I love Bubble Gum ║║ <3 ║ +║ ║║ ║ +╚═══════════════════════════╝╚════════════╝ +``` + + ## Feedback We’d love to hear your thoughts on this project. Feel free to drop us a note! @@ -96,8 +116,6 @@ We’d love to hear your thoughts on this project. Feel free to drop us a note! [MIT](https://github.com/charmbracelet/seashell/raw/main/LICENSE) -*** - Part of [Charm](https://charm.sh). The Charm logo diff --git a/gum.go b/gum.go index 9cc52a9..27fdf17 100644 --- a/gum.go +++ b/gum.go @@ -30,7 +30,7 @@ type Gum struct { // // $ gum write > output.text // - Write write.Options `cmd:"" help:"Prompt for text"` + Write write.Options `cmd:"" help:"Prompt for multi-line input."` // Search provides a fuzzy searching text input to allow filtering a list of // options to select one option. @@ -98,5 +98,5 @@ type Gum struct { // Join provides a shell script interface for the lipgloss JoinHorizontal // and JoinVertical commands. // - Join join.Options `cmd:"" help:"Join text horizontally or vertically"` + Join join.Options `cmd:"" help:"Join text horizontally or vertically."` }