gum.go
This file
Path
gum.go
228 lines · 8.8 KiB · Go
Last changed by
chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
History of this fileTake it
The walk stopped after 200 commits: lines older than 6837ed2 point at it.
feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 1–5why, one step back1package main23import (4 "github.com/alecthomas/kong"5chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
lines 6–21why, one step back6 "charm.land/gum/v2/choose"7 "charm.land/gum/v2/completion"8 "charm.land/gum/v2/confirm"9 "charm.land/gum/v2/file"10 "charm.land/gum/v2/filter"11 "charm.land/gum/v2/format"12 "charm.land/gum/v2/input"13 "charm.land/gum/v2/join"14 "charm.land/gum/v2/log"15 "charm.land/gum/v2/man"16 "charm.land/gum/v2/pager"17 "charm.land/gum/v2/spin"18 "charm.land/gum/v2/style"19 "charm.land/gum/v2/table"20 "charm.land/gum/v2/version"21 "charm.land/gum/v2/write"feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 22–136why, one step back22)2324// Gum is the command-line interface for Gum.25type Gum struct {26 // Version is a flag that can be used to display the version number.27 Version kong.VersionFlag `short:"v" help:"Print the version number"`2829 // Completion generates Gum shell completion scripts.30 Completion completion.Completion `cmd:"" hidden:"" help:"Request shell completion"`3132 // Man is a hidden command that generates Gum man pages.33 Man man.Man `cmd:"" hidden:"" help:"Generate man pages"`3435 // Choose provides an interface to choose one option from a given list of36 // options. The options can be provided as (new-line separated) stdin or a37 // list of arguments.38 //39 // It is different from the filter command as it does not provide a fuzzy40 // finding input, so it is best used for smaller lists of options.41 //42 // Let's pick from a list of gum flavors:43 //44 // $ gum choose "Strawberry" "Banana" "Cherry"45 //46 Choose choose.Options `cmd:"" help:"Choose an option from a list of choices"`4748 // Confirm provides an interface to ask a user to confirm an action.49 // The user is provided with an interface to choose an affirmative or50 // negative answer, which is then reflected in the exit code for use in51 // scripting.52 //53 // If the user selects the affirmative answer, the program exits with 0.54 // If the user selects the negative answer, the program exits with 1.55 //56 // I.e. confirm if the user wants to delete a file57 //58 // $ gum confirm "Are you sure?" && rm file.txt59 //60 Confirm confirm.Options `cmd:"" help:"Ask a user to confirm an action"`6162 // File provides an interface to pick a file from a folder (tree).63 // The user is provided a file manager-like interface to navigate, to64 // select a file.65 //66 // Let's pick a file from the current directory:67 //68 // $ gum file69 // $ gum file .70 //71 // Let's pick a file from the home directory:72 //73 // $ gum file $HOME74 File file.Options `cmd:"" help:"Pick a file from a folder"`7576 // Filter provides a fuzzy searching text input to allow filtering a list of77 // options to select one option.78 //79 // By default it will list all the files (recursively) in the current directory80 // for the user to choose one, but the script (or user) can provide different81 // new-line separated options to choose from.82 //83 // I.e. let's pick from a list of gum flavors:84 //85 // $ cat flavors.text | gum filter86 //87 Filter filter.Options `cmd:"" help:"Filter items from a list"`8889 // Format allows you to render styled text from `markdown`, `code`,90 // `template` strings, or embedded `emoji` strings.91 // For more information see the format/README.md file.92 Format format.Options `cmd:"" help:"Format a string using a template"`9394 // Input provides a shell script interface for the text input bubble.95 // https://github.com/charmbracelet/bubbles/tree/master/textinput96 //97 // It can be used to prompt the user for some input. The text the user98 // entered will be sent to stdout.99 //100 // $ gum input --placeholder "What's your favorite gum?" > answer.text101 //102 Input input.Options `cmd:"" help:"Prompt for some input"`103104 // Join provides a shell script interface for the lipgloss JoinHorizontal105 // and JoinVertical commands. It allows you to join multi-line text to106 // build different layouts.107 //108 // For example, you can place two bordered boxes next to each other:109 // Note: We wrap the variable in quotes to ensure the new lines are part of a110 // single argument. Otherwise, the command won't work as expected.111 //112 // $ gum join --horizontal "$BUBBLE_BOX" "$GUM_BOX"113 //114 // ╔══════════════════════╗╔═════════════╗115 // ║ ║║ ║116 // ║ Bubble ║║ Gum ║117 // ║ ║║ ║118 // ╚══════════════════════╝╚═════════════╝119 //120 Join join.Options `cmd:"" help:"Join text vertically or horizontally"`121122 // Pager provides a shell script interface for the viewport bubble.123 // https://github.com/charmbracelet/bubbles/tree/master/viewport124 //125 // It allows the user to scroll through content like a pager.126 //127 // ╭────────────────────────────────────────────────╮128 // │ 1 │ Gum Pager │129 // │ 2 │ ========= │130 // │ 3 │ │131 // │ 4 │ ``` │132 // │ 5 │ gum pager --height 10 --width 25 < text │133 // │ 6 │ ``` │134 // │ 7 │ │135 // │ 8 │ │136 // ╰────────────────────────────────────────────────╯feat(choose,confirm,file,filter,input,table,write): esc exit 1, ctrl+c exit 130, help arrow order (#771)Carlos Alexandro Beckerbefore adoption774667a
line 137why, one step back137 // ↓↑: navigate • q: quitfeat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 138–144why, one step back138 //139 Pager pager.Options `cmd:"" help:"Scroll through a file"`140141 // Spin provides a shell script interface for the spinner bubble.142 // https://github.com/charmbracelet/bubbles/tree/master/spinner143 //144 // It is useful for displaying that some task is running in the backgrounddocs: fix typo in spinner comment (#1032)Rohan Santhosh Kumarbefore adoptiondd35798
line 145why, one step back145 // while consuming its output so that it is not shown to the user.feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 146–217why, one step back146 //147 // For example, let's do a long running task: $ sleep 5148 //149 // We can simply prepend a spinner to this task to show it to the user,150 // while performing the task / command in the background.151 //152 // $ gum spin -t "Taking a nap..." -- sleep 5153 //154 // The spinner will automatically exit when the task is complete.155 //156 Spin spin.Options `cmd:"" help:"Display spinner while running a command"`157158 // Style provides a shell script interface for Lip Gloss.159 // https://github.com/charmbracelet/lipgloss160 //161 // It allows you to use Lip Gloss to style text without needing to use Go.162 // All of the styling options are available as flags.163 //164 // Let's make some text glamorous using bash:165 //166 // $ gum style \167 // --foreground 212 --border double --align center \168 // --width 50 --margin 2 --padding "2 4" \169 // "Bubble Gum (1¢)" "So sweet and so fresh\!"170 //171 //172 // ╔══════════════════════════════════════════════════╗173 // ║ ║174 // ║ ║175 // ║ Bubble Gum (1¢) ║176 // ║ So sweet and so fresh! ║177 // ║ ║178 // ║ ║179 // ╚══════════════════════════════════════════════════╝180 //181 Style style.Options `cmd:"" help:"Apply coloring, borders, spacing to text"`182183 // Table provides a shell script interface for the table bubble.184 // https://github.com/charmbracelet/bubbles/tree/master/table185 //186 // It is useful to render tabular (CSV) data in a terminal and allows187 // the user to select a row from the table.188 //189 // Let's render a table of gum flavors:190 //191 // $ gum table <<< "Flavor,Price\nStrawberry,$0.50\nBanana,$0.99\nCherry,$0.75"192 //193 // Flavor Price194 // Strawberry $0.50195 // Banana $0.99196 // Cherry $0.75197 //198 Table table.Options `cmd:"" help:"Render a table of data"`199200 // Write provides a shell script interface for the text area bubble.201 // https://github.com/charmbracelet/bubbles/tree/master/textarea202 //203 // It can be used to ask the user to write some long form of text204 // (multi-line) input. The text the user entered will be sent to stdout.205 //206 // $ gum write > output.text207 //208 Write write.Options `cmd:"" help:"Prompt for long-form text"`209210 // Log provides a shell script interface for logging using Log.211 // https://github.com/charmbracelet/log212 //213 // It can be used to log messages to output.214 //215 // $ gum log --level info "Hello, world!"216 //217 Log log.Options `cmd:"" help:"Log messages to output"`feat(version): adds command to check current gum version (#775)Carlos Alexandro Beckerbefore adoption64d69eb
lines 218–227why, one step back218219 // VersionCheck provides a command that checks if the current gum version220 // matches a given semantic version constraint.221 //222 // It can be used to check that a minimum gum version is installed in a223 // script.224 //225 // $ gum version-check '~> 0.15'226 //227 VersionCheck version.Options `cmd:"" help:"Semver check current gum version"`feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 228why, one step back228}