github.com/wolfi-dev/wolfictl@v0.16.11/pkg/cli/components/accept/accept.go (about)

     1  package accept
     2  
     3  import (
     4  	"fmt"
     5  
     6  	tea "github.com/charmbracelet/bubbletea"
     7  	"github.com/wolfi-dev/wolfictl/pkg/cli/styles"
     8  )
     9  
    10  type Model struct {
    11  	// Accepted is true if the message was accepted by the user.
    12  	Accepted bool
    13  }
    14  
    15  func (m Model) Init() tea.Cmd {
    16  	return nil
    17  }
    18  
    19  func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    20  	keyMsg, ok := msg.(tea.KeyMsg)
    21  	if ok && keyMsg.String() == "enter" {
    22  		m.Accepted = true
    23  	}
    24  
    25  	return m, nil
    26  }
    27  
    28  func (m Model) View() string {
    29  	if m.Accepted {
    30  		return ""
    31  	}
    32  
    33  	return fmt.Sprintf("%s\n", helpAccept)
    34  }
    35  
    36  var (
    37  	helpAccept = fmt.Sprintf(
    38  		"%s %s",
    39  		styleHelpKey.Render("enter"),
    40  		styleHelpExplanation.Render("to move on."),
    41  	)
    42  )
    43  
    44  var (
    45  	styleHelpKey         = styles.FaintAccent().Copy().Bold(true)
    46  	styleHelpExplanation = styles.Faint().Copy()
    47  )