bubblewrap

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 9 Imported by: 2

README

bubblewrap

bubblewrap is a library that wraps around the Charmbracelet bubbletea library to provide a simpler API for building CLI applications that require input from users, without the complexity of managing the model, view, update constructs underlying the ELM architecture that Bubbletea and other Charmbracelet libraries are built on.

As a CLI developer, I commonly want to prompt users for things or let them choose from a menu of options. In some cases, these CLIs need fancy / robust state management and presentation details, which the Charmbracelet ecosystem tools are perfect for. However, in an equal (if not greater) number of cases, I want the elegance and flexibility of the Charmbracelet tools, but don't need to do things like store / mutate / view the state of things done by the CLI. I just want present users with a nice looking, consistently styled interface to get the information I need, then do the work in simpler ways without fancy TUIs. This is why I wrote bubblewrap, so that I could have an easy API / entrypoint into common operations without constantly writing the same boilerplate code around things like handling different kinds of key presses.

PRs for additional features are welcome!

Examples can be found in the examples directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Choose

func Choose(options []string, optFns ...func(*chooser) error) ([]string, error)

Choose lets you prompt the user with a list of options and allows them to select one or more of them.

func Input

func Input(prompt string) (string, error)

Input prompts for, well, input!

func NewChooser

func NewChooser(options []string, opts ...func(*chooser) error) (*chooser, error)

func NewInputter

func NewInputter() *inputter

func WithCursorStyle

func WithCursorStyle(style lipgloss.Style) func(*chooser) error

WithCursorStyle sets the lipgloss Style for the rendered cursor. See https://github.com/charmbracelet/lipgloss.

func WithItemStyle

func WithItemStyle(style lipgloss.Style) func(*chooser) error

WithItemStyle stes the lipgloss Style for non selected items in the list. See https://github.com/charmbracelet/lipgloss.

func WithSelectedItemStyle

func WithSelectedItemStyle(style lipgloss.Style) func(*chooser) error

WithSelectedItemStyle stes the lipgloss Style for selected items in the list. See https://github.com/charmbracelet/lipgloss.

Types

type CancelError

type CancelError error

CancelError is returned when the user indicates they want the input to be cancelled, by using the escape or Control C inputs.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL