command

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ConfirmFlag = "confirm"
View Source
const (
	EnumType = "enum"
)
View Source
const (
	TimeType = "time"
)

Variables

View Source
var ErrActionNotAllowed = errors.New("you are not allowed to take this action")
View Source
var ErrTokenExpired = errors.New("your token is expired; run `render login` to get a new one")
View Source
var RFC3339RegexString = []string{
	`\d`, `\d`, `\d`, `\d`, `-`, `\d`, `\d`, `-`, `\d`, `\d`,
	`T`, `\d`, `\d`, `:`, `\d`, `\d`, `:`, `\d`, `\d`,
}

Functions

func AddErrToStack

func AddErrToStack(ctx context.Context, cmd *cobra.Command, err error) tea.Cmd

func AddToStack

func AddToStack[T any](stack *tui.StackModel, cmd *cobra.Command, breadcrumb string, in T, m tea.Model) tea.Cmd

func AddToStackFunc

func AddToStackFunc[T any](ctx context.Context, cmd *cobra.Command, breadcrumb string, in T, m tea.Model) tea.Cmd

func CommandName

func CommandName(cmd *cobra.Command, v any) (string, error)

func DefaultFormatNonInteractive

func DefaultFormatNonInteractive(cmd *cobra.Command)

func Fatal

func Fatal(cmd *cobra.Command, err error)

func GetConfirmFromContext

func GetConfirmFromContext(ctx context.Context) bool

func InputToString

func InputToString(v any) (string, error)

func LoadCmd

func LoadCmd[T any, D any](ctx context.Context, loadData func(context.Context, T) (D, error), in T) tui.TypedCmd[D]

func NewStringFormValue

func NewStringFormValue(s string) *stringFormValue

func NewStringSliceFormValue

func NewStringSliceFormValue(s string) *stringSliceFormValue

func NonInteractive

func NonInteractive[T any](cmd *cobra.Command, loadData LoadDataFunc[T], formatText FormatTextFunc[T]) (bool, error)

func NonInteractiveWithConfirm

func NonInteractiveWithConfirm[T any](cmd *cobra.Command, loadData LoadDataFunc[T], formatText FormatTextFunc[T], confirmMessageFunc ConfirmFunc) (bool, error)

func PaginatedLoadCmd

func PaginatedLoadCmd[T any, D any](ctx context.Context, loadData func(context.Context, T, client.Cursor) (client.Cursor, D, error), in T) tui.TypedCmd[D]

func ParseCommand

func ParseCommand(cmd *cobra.Command, args []string, v any) error

func ParseCommandInteractiveOnly

func ParseCommandInteractiveOnly(cmd *cobra.Command, args []string, v any) error

func PrintData

func PrintData[T any](cmd *cobra.Command, data T, formatText FormatTextFunc[T]) (bool, error)

func Println

func Println(cmd *cobra.Command, format string, a ...any)

func RunProgram

func RunProgram(name string, args ...string) error

func SetConfirmInContext

func SetConfirmInContext(ctx context.Context, confirm bool) context.Context

func SetFormatInContext

func SetFormatInContext(ctx context.Context, output *Output) context.Context

func StructFromFormValues

func StructFromFormValues(formValues FormValues, v any) error

func TimeSuggestion

func TimeSuggestion(str string) []string

func WrapInConfirm

func WrapInConfirm[D any](cmd tui.TypedCmd[D], msgFunc func() (string, error)) tui.TypedCmd[D]

Types

type CTXConfirmKey

type CTXConfirmKey struct{}

type CTXConfirmValue

type CTXConfirmValue struct {
	Confirm bool
}

type CTXOutputKey

type CTXOutputKey struct{}

type CTXOutputValue

type CTXOutputValue struct {
	Output *Output
}

type CobraEnum

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

func NewEnumInput

func NewEnumInput(values []string, isMultiSelect bool) *CobraEnum

func (*CobraEnum) IsMultiSelect

func (e *CobraEnum) IsMultiSelect() bool

func (*CobraEnum) SelectedValues

func (e *CobraEnum) SelectedValues() []string

func (*CobraEnum) Set

func (e *CobraEnum) Set(v string) error

func (*CobraEnum) String

func (e *CobraEnum) String() string

func (*CobraEnum) Type

func (e *CobraEnum) Type() string

func (*CobraEnum) Values

func (e *CobraEnum) Values() []string

type CobraTime

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

func NewTimeInput

func NewTimeInput() *CobraTime

func (*CobraTime) Get

func (e *CobraTime) Get() *TimeOrRelative

func (*CobraTime) Set

func (e *CobraTime) Set(v string) error

func (*CobraTime) String

func (e *CobraTime) String() string

func (*CobraTime) Type

func (e *CobraTime) Type() string

type ConfirmFunc

type ConfirmFunc func() (string, error)

type FormValue

type FormValue interface {
	String() string
}

type FormValues

type FormValues map[string]FormValue

func FormValuesFromStruct

func FormValuesFromStruct(v any) FormValues

func HuhFormFields

func HuhFormFields(cmd *cobra.Command, v any) ([]huh.Field, FormValues)

type FormatTextFunc

type FormatTextFunc[T any] func(T) string

type InteractiveFunc

type InteractiveFunc[T any, D any] func(context.Context, func(T) tui.TypedCmd[D], T) (tea.Model, error)

type LoadDataFunc

type LoadDataFunc[T any] func() (T, error)

type Output

type Output string
const (
	Interactive Output = "interactive"
	JSON        Output = "json"
	YAML        Output = "yaml"
	TEXT        Output = "text"
)

func GetFormatFromContext

func GetFormatFromContext(ctx context.Context) *Output

func StringToOutput

func StringToOutput(s string) (Output, error)

func (*Output) Interactive

func (o *Output) Interactive() bool

type RequireConfirm

type RequireConfirm[T any] struct {
	Confirm     bool
	MessageFunc func(ctx context.Context, args T) (string, error)
}

type TextTable

type TextTable interface {
	Header() []string
	Row() []string
}

type TimeOrRelative

type TimeOrRelative struct {
	T        *time.Time
	Relative *string
}

func ParseTime

func ParseTime(now time.Time, str *string) (*TimeOrRelative, error)

func (*TimeOrRelative) String

func (t *TimeOrRelative) String() string

type WrapOptions

type WrapOptions[T any] struct {
	RequireConfirm RequireConfirm[T]
}

type WrappedFunc

type WrappedFunc[T any] func(ctx context.Context, args T) tea.Cmd

Jump to

Keyboard shortcuts

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