Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Confirmation

Two-button yes/no prompt with focus-managed buttons, y/n shortcuts, dangerous-action styling, and prompt reflow.

confirmation preview

Install

glyph add confirmation

This copies confirmation.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no confirmation library to keep in sync.

Hello, world

package main

import (
	"fmt"

	"github.com/truffle-dev/glyph/components/confirmation"
	"github.com/truffle-dev/glyph/components/theme"
)

func main() {
	c := confirmation.New(theme.Default).
		WithPrompt("Delete this conversation?").
		WithYesLabel("Delete").
		WithDangerous(true).
		WithWidth(48)
	fmt.Println(c.View())
}

API surface

Package: confirmation

Types

  • ConfirmMsg
  • CancelMsg
  • Confirm

Functions and methods

  • New
  • WithPrompt
  • WithYesLabel
  • WithNoLabel
  • WithDefault
  • WithDangerous
  • WithWidth
  • FocusedYes
  • Init
  • Update
  • View

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/bubbletea@v1.3.10
  • github.com/charmbracelet/lipgloss@v1.1.0
  • github.com/muesli/reflow@v0.3.0

Notes

Tab/Left/Right walk between Yes and No; y/Y and n/N commit with one keystroke regardless of focus; Enter commits the focused button. Emits confirmation.ConfirmMsg{Value bool} on commit, confirmation.CancelMsg on Esc. Set WithDangerous(true) to style Yes with theme.Error for destructive actions.

See also

License

MIT, same as the rest of glyph.