cprompt

package module
v0.0.0-...-416f72b Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 14 Imported by: 0

README

bubbleprompt-cobra

Easily integrate bubbleprompt with cobra

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Completer

func Completer[T any](cmd *cobra.Command, f func(cmd *cobra.Command, args []string,
	toComplete string) ([]suggestion.Suggestion[commandinput.CommandMetadata[T]], error),
)

func ExecModel

func ExecModel(cmd *cobra.Command, model tea.Model) error

func FilterShellCompletions

func FilterShellCompletions[T any](options []string, toComplete string) []string

func FilterShellCompletionsWith

func FilterShellCompletionsWith[T any](options []string, toComplete string,
	filterer completer.Filterer[commandinput.CommandMetadata[T]],
) []string

func PreservePlaceholder

func PreservePlaceholder(cmd *cobra.Command, flag string)

func ShowFlagPlaceholder

func ShowFlagPlaceholder(cmd *cobra.Command, show bool)

Types

type CompleterStart

type CompleterStart[T any] func(promptModel prompt.Model[commandinput.CommandMetadata[T]])

type ExecutorFinish

type ExecutorFinish func(model tea.Model, err error) (tea.Model, error)

type ExecutorStart

type ExecutorStart[T any] func(input string, selectedSuggestion *suggestion.Suggestion[commandinput.CommandMetadata[T]])

type Model

type Model[T any] struct {
	// contains filtered or unexported fields
}

func NewPrompt

func NewPrompt[T any](cmd *cobra.Command, options ...Option[T]) Model[T]

func (Model[T]) Init

func (m Model[T]) Init() tea.Cmd

func (*Model[T]) SetFilterer

func (m *Model[T]) SetFilterer(filterer completer.Filterer[commandinput.CommandMetadata[T]])

func (*Model[T]) SetIgnoreCmds

func (m *Model[T]) SetIgnoreCmds(ignoreCmds ...string)

func (*Model[T]) SetOnCompleterFinish

func (m *Model[T]) SetOnCompleterFinish(onCompleterFinish CompleterFinish[T])

func (*Model[T]) SetOnCompleterStart

func (m *Model[T]) SetOnCompleterStart(onCompleterStart CompleterStart[T])

func (*Model[T]) SetOnExecutorFinish

func (m *Model[T]) SetOnExecutorFinish(onExecutorFinish ExecutorFinish)

func (*Model[T]) SetOnExecutorStart

func (m *Model[T]) SetOnExecutorStart(onExecutorStart ExecutorStart[T])

func (Model[T]) Start

func (m Model[T]) Start() error

func (Model[T]) Update

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

func (Model[T]) View

func (m Model[T]) View() string

type Option

type Option[T any] func(model *Model[T])

func WithIgnoreCmds

func WithIgnoreCmds[T any](cmds ...string) Option[T]

func WithOnCompleterFinish

func WithOnCompleterFinish[T any](onCompleterStart CompleterFinish[T]) Option[T]

func WithOnCompleterStart

func WithOnCompleterStart[T any](onCompleterStart CompleterStart[T]) Option[T]

func WithOnExecutorFinish

func WithOnExecutorFinish[T any](onExecutorFinish ExecutorFinish) Option[T]

func WithOnExecutorStart

func WithOnExecutorStart[T any](onExecutorStart ExecutorStart[T]) Option[T]

func WithPromptOptions

func WithPromptOptions[T any](options ...prompt.Option[commandinput.CommandMetadata[T]]) Option[T]

Jump to

Keyboard shortcuts

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