input

package
v0.0.0-...-6f7621a Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package input provides functionality that makes use of the github.com/charmbracelet/bubbletea package for terminal input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a custom github.com/charmbracelet/bubbletea#Model that reads the filename of a new note.

func NewModel

func NewModel(schema string, examples []string) Model

NewModel creates a new Model type.

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements the bubbletea.Model.Init() interface.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements the bubbletea.Model.Update() interface.

func (Model) View

func (m Model) View() string

View implements the bubbletea.Model.View() interface.

type ReturnValue

type ReturnValue struct {
	Filename string `json:"filename"`
	Prompt   string `json:"prompt"`
}

ReturnValue is a hack to allow the charmbracelet/bubbletea#Model to return the latest value from the terminal input whilst also preserving the prompt. This is due to charmbracelet/bubbletea#Program.StartReturningModel returning an interface which does not expose this value, thus instead when the .Update() function of model has completed, the .View() function of the model will return a JSON string instead of the raw prompt output. This allows the consuming package to print the prompt a final time, thus preserving it for the user, as well as having access to the raw value.

Jump to

Keyboard shortcuts

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