cli

package
v0.0.0-...-5bb4afb Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ModeNorm selectListMode = iota
	ModeSearch
)
View Source
const (
	ParamInputHintSymbol = ">"
	PromptTypeFile       = "FILE   "
	PromptTypeDir        = "DIR    "
	PromptTypeDefault    = "DEFAULT"
	PromptTypeHistory    = "HISTORY"
)

Variables

View Source
var (
	MaxItemHistoryBucket = 100
)

Functions

func Confirm

func Confirm(label string, defaultY bool) bool

Confirm with y/n

func FixedSelect

func FixedSelect(label string, choices []string, opt ...SelectFn) (int, string)

func Input

func Input(label string, fns ...InputOption) string

func InputPassword

func InputPassword(label string, validateFunc func(string) error) string

InputPassword with mask

func InterruptableInput

func InterruptableInput(label string, fns ...InputOption) (text string, interrupted bool)

func PressEnterToContinue

func PressEnterToContinue()

func PressEnterToContinueWithHint

func PressEnterToContinueWithHint(hint string)

func Select

func Select(label string, choices []string, opt ...SelectFn) (int, string)

Select from menu

func SelectWithSearch

func SelectWithSearch(label string, choices []string, opt ...SelectFn) int

SelectWithSearch from menu

func WithProgress

func WithProgress(name string, duration time.Duration, fn func())

Types

type BucketKV

type BucketKV struct {
	DB *FileDB
	// contains filtered or unexported fields
}

func (*BucketKV) Delete

func (kv *BucketKV) Delete(key string) error

func (*BucketKV) Get

func (kv *BucketKV) Get(key string, valPtr interface{}) error

func (*BucketKV) GetBytes

func (kv *BucketKV) GetBytes(key string) []byte

func (*BucketKV) GetString

func (kv *BucketKV) GetString(key string) string

func (*BucketKV) Put

func (kv *BucketKV) Put(key string, val interface{}) error

func (*BucketKV) PutWithTTL

func (kv *BucketKV) PutWithTTL(key string, val interface{}, ttlSec uint32) error

type ComplexSelect

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

func NewComplexSelect

func NewComplexSelect(initialIndex int, items []string) *ComplexSelect

func NewComplexSelectWithHints

func NewComplexSelectWithHints(initialIndex int, items, hints []string) *ComplexSelect

func (*ComplexSelect) InNormMode

func (sl *ComplexSelect) InNormMode() bool

func (*ComplexSelect) InSearchMode

func (sl *ComplexSelect) InSearchMode() bool

InSearchMode is in search mode

func (*ComplexSelect) IsSelectNothing

func (sl *ComplexSelect) IsSelectNothing() bool

IsSelectNothing true: exit with nothing selected

func (*ComplexSelect) Selected

func (sl *ComplexSelect) Selected() int

Selected return selected index

func (*ComplexSelect) Show

func (slist *ComplexSelect) Show()

type FileDB

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

func MustNewHomeFileDB

func MustNewHomeFileDB(ns ...string) *FileDB

func NewFileDB

func NewFileDB(dbdir string) (*FileDB, error)

func NewHomeFileDB

func NewHomeFileDB(ns ...string) (*FileDB, error)

func (*FileDB) Close

func (fdb *FileDB) Close()

func (*FileDB) GetBucketKV

func (fdb *FileDB) GetBucketKV(bucket string) *BucketKV

func (*FileDB) GetItemHistoryBucket

func (fdb *FileDB) GetItemHistoryBucket(bucket string, size int) *ItemHistoryBucket

type InputOption

type InputOption func(*inputOption)

func WithFileBrowser

func WithFileBrowser() InputOption

func WithHint

func WithHint() InputOption

func WithRecentName

func WithRecentName(ns string) InputOption

func WithSuggestions

func WithSuggestions(list []Suggest) InputOption

func WithValidator

func WithValidator(v func(string) error) InputOption

type ItemHistoryBucket

type ItemHistoryBucket struct {
	DB *FileDB
	// contains filtered or unexported fields
}

func (*ItemHistoryBucket) InsertItem

func (ih *ItemHistoryBucket) InsertItem(v interface{}) error

func (*ItemHistoryBucket) ListItem

func (ih *ItemHistoryBucket) ListItem(retSlicePtr interface{}) error

type Keyer

type Keyer interface {
	GetKey() string
}

type MatchedTerm

type MatchedTerm struct {
	Text string
	Term
}

func (MatchedTerm) IsMatched

func (mt MatchedTerm) IsMatched() bool

type Progress

type Progress struct {
	Bars []ProgressBar
	// contains filtered or unexported fields
}

func NewProgress

func NewProgress() *Progress

func (*Progress) NewBar

func (p *Progress) NewBar(name string, duration time.Duration) ProgressBar

func (*Progress) Stop

func (b *Progress) Stop()

type ProgressBar

type ProgressBar interface {
	Finish()
	Cancel()
}

type SearchObj

type SearchObj struct {
	// filted results indices after searching
	SearchResultsIndices []int
	// cursor location, index of SearchResultsIndices
	SelectedResultIndex int
	// current query string
	QueryStr string
	// base title displayed when searching
	SearchTitle string
	// contains filtered or unexported fields
}

func (*SearchObj) Current

func (so *SearchObj) Current() int

func (*SearchObj) Next

func (so *SearchObj) Next() int

func (*SearchObj) Prev

func (so *SearchObj) Prev() int

func (*SearchObj) Title

func (so *SearchObj) Title() string

type SelectFn

type SelectFn func(*SelectWidget)

type SelectWidget

type SelectWidget = promptui.Select

type Style

type Style = gotable.Style

type Suggest

type Suggest struct {
	Text string
	Desc string
}

func (Suggest) GetKey

func (s Suggest) GetKey() string

type Table

type Table interface {
	SetHeader(v ...interface{}) Table
	AddRow(v ...interface{}) Table
	SetStyle(Style) Table
	SetOutput(w io.Writer)
	Render()
}

func NewTable

func NewTable() Table

type Term

type Term struct {
	Name         string
	PrefixRegexp string
	SuffixSymbol string
}

type TermWriter

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

func NewTermWriter

func NewTermWriter() *TermWriter

func (*TermWriter) AddTerm

func (b *TermWriter) AddTerm(name string, prefixReg string, endingText string) error

func (*TermWriter) DataChan

func (b *TermWriter) DataChan() <-chan MatchedTerm

func (*TermWriter) Stop

func (b *TermWriter) Stop()

func (*TermWriter) Write

func (b *TermWriter) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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