console

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 33 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BrandColor = lipgloss.CompleteColor{TrueColor: "#3D8C8D", ANSI256: "30", ANSI: "6"}
	MutedColor = lipgloss.CompleteColor{TrueColor: "#4a4a4a", ANSI256: "240", ANSI: "8"}
	WhiteColor = lipgloss.CompleteColor{TrueColor: "#ffffff", ANSI256: "255", ANSI: "15"}

	DefaultProgressBarStyle   = pterm.NewStyle(pterm.FgLightGreen)
	DefaultProgressTitleStyle = pterm.NewStyle(pterm.FgWhite)

	DefaultTableHeaderColor = BrandColor
	DefaultTableBorderColor = MutedColor

	DefaultTableHeaderStyle  = lipgloss.NewStyle().Foreground(DefaultTableHeaderColor).Bold(true).Padding(0, 1)
	DefaultTableCellStyle    = lipgloss.NewStyle().Padding(0, 1)
	DefaultSpinnerStyle      = lipgloss.NewStyle().Foreground(BrandColor)
	DefaultSpinnerTitleStyle = lipgloss.NewStyle().Foreground(BrandColor)

	DefaultTableStyleFunc = func(row, col int) lipgloss.Style {
		if row == table.HeaderRow {
			return DefaultTableHeaderStyle
		}
		return DefaultTableCellStyle
	}

	DefaultTableOption = console.TableOption{
		Border: lipgloss.RoundedBorder(),

		BorderStyle: lipgloss.NewStyle().Foreground(DefaultTableBorderColor),

		StyleFunc: DefaultTableStyleFunc,

		BorderTop:    convert.Pointer(true),
		BorderBottom: convert.Pointer(true),
		BorderLeft:   convert.Pointer(true),
		BorderRight:  convert.Pointer(true),
		BorderHeader: convert.Pointer(true),
		BorderColumn: convert.Pointer(true),
		BorderRow:    convert.Pointer(false),
	}

	GlobalHuhTheme = func() *huh.Theme {
		t := huh.ThemeCharm()
		t.Focused.Title = t.Focused.Title.Foreground(BrandColor)
		t.Focused.TextInput.Prompt = t.Focused.TextInput.Prompt.Foreground(BrandColor)
		t.Focused.TextInput.Cursor = t.Focused.TextInput.Cursor.Foreground(BrandColor)
		t.Focused.Base = t.Focused.Base.BorderForeground(BrandColor)

		t.Focused.SelectedOption = t.Focused.SelectedOption.Foreground(BrandColor)
		t.Focused.MultiSelectSelector = t.Focused.MultiSelectSelector.Foreground(BrandColor)

		t.Focused.FocusedButton = t.Focused.FocusedButton.
			Background(BrandColor).
			Foreground(WhiteColor)

		return t
	}()
)

Functions

func FilterCommandsByAllowlist added in v1.18.0

func FilterCommandsByAllowlist(commands []console.Command, allowlist []string) []console.Command

FilterCommandsByAllowlist returns the subset of commands whose Signature() matches at least one entry in allowlist.

Matching is signature-only (category never consulted):

  • Entries without '*' are exact-matched against command.Signature().
  • Entries containing '*' use glob matching via path.Match against command.Signature() (only '*' triggers the glob path; '?' is matched literally as an exact match).

Special cases:

  • allowlist == nil → every command is kept (no filter applied).
  • allowlist resolves to no usable entries → every command is dropped.

Types

type Application

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

func NewApplication added in v1.8.1

func NewApplication(name, usage, usageText, version string, useArtisan bool) *Application

NewApplication Create a new Artisan application. Will add artisan flag to the command if useArtisan is true.

func (*Application) Call added in v0.1.0

func (r *Application) Call(command string) error

Call Run an Artisan console command by name.

func (*Application) CallAndExit added in v0.4.1

func (r *Application) CallAndExit(command string)

CallAndExit Run an Artisan console command by name and exit.

func (*Application) Register

func (r *Application) Register(commands []console.Command)

Register commands to the application.

func (*Application) Run added in v0.1.2

func (r *Application) Run(args []string, exitIfArtisan bool) error

Run a command. Args come from os.Args.

func (*Application) SetCommands added in v1.17.0

func (r *Application) SetCommands(commands []console.Command)

SetCommands Set the commands for the application.

type CliContext added in v1.0.0

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

func NewCliContext added in v1.14.0

func NewCliContext(ctx context.Context, instance *cli.Command, arguments []command.Argument) *CliContext

func (*CliContext) Argument added in v1.0.0

func (r *CliContext) Argument(index int) string

func (*CliContext) ArgumentFloat32 added in v1.17.0

func (r *CliContext) ArgumentFloat32(key string) float32

func (*CliContext) ArgumentFloat32Slice added in v1.17.0

func (r *CliContext) ArgumentFloat32Slice(key string) []float32

func (*CliContext) ArgumentFloat64 added in v1.17.0

func (r *CliContext) ArgumentFloat64(key string) float64

func (*CliContext) ArgumentFloat64Slice added in v1.17.0

func (r *CliContext) ArgumentFloat64Slice(key string) []float64

func (*CliContext) ArgumentInt added in v1.17.0

func (r *CliContext) ArgumentInt(key string) int

func (*CliContext) ArgumentInt8 added in v1.17.0

func (r *CliContext) ArgumentInt8(key string) int8

func (*CliContext) ArgumentInt8Slice added in v1.17.0

func (r *CliContext) ArgumentInt8Slice(key string) []int8

func (*CliContext) ArgumentInt16 added in v1.17.0

func (r *CliContext) ArgumentInt16(key string) int16

func (*CliContext) ArgumentInt16Slice added in v1.17.0

func (r *CliContext) ArgumentInt16Slice(key string) []int16

func (*CliContext) ArgumentInt32 added in v1.17.0

func (r *CliContext) ArgumentInt32(key string) int32

func (*CliContext) ArgumentInt32Slice added in v1.17.0

func (r *CliContext) ArgumentInt32Slice(key string) []int32

func (*CliContext) ArgumentInt64 added in v1.17.0

func (r *CliContext) ArgumentInt64(key string) int64

func (*CliContext) ArgumentInt64Slice added in v1.17.0

func (r *CliContext) ArgumentInt64Slice(key string) []int64

func (*CliContext) ArgumentIntSlice added in v1.17.0

func (r *CliContext) ArgumentIntSlice(key string) []int

func (*CliContext) ArgumentString added in v1.17.0

func (r *CliContext) ArgumentString(key string) string

func (*CliContext) ArgumentStringSlice added in v1.17.0

func (r *CliContext) ArgumentStringSlice(key string) []string

func (*CliContext) ArgumentTimestamp added in v1.17.0

func (r *CliContext) ArgumentTimestamp(key string) time.Time

func (*CliContext) ArgumentTimestampSlice added in v1.17.0

func (r *CliContext) ArgumentTimestampSlice(key string) []time.Time

func (*CliContext) ArgumentUint added in v1.17.0

func (r *CliContext) ArgumentUint(key string) uint

func (*CliContext) ArgumentUint8 added in v1.17.0

func (r *CliContext) ArgumentUint8(key string) uint8

func (*CliContext) ArgumentUint8Slice added in v1.17.0

func (r *CliContext) ArgumentUint8Slice(key string) []uint8

func (*CliContext) ArgumentUint16 added in v1.17.0

func (r *CliContext) ArgumentUint16(key string) uint16

func (*CliContext) ArgumentUint16Slice added in v1.17.0

func (r *CliContext) ArgumentUint16Slice(key string) []uint16

func (*CliContext) ArgumentUint32 added in v1.17.0

func (r *CliContext) ArgumentUint32(key string) uint32

func (*CliContext) ArgumentUint32Slice added in v1.17.0

func (r *CliContext) ArgumentUint32Slice(key string) []uint32

func (*CliContext) ArgumentUint64 added in v1.17.0

func (r *CliContext) ArgumentUint64(key string) uint64

func (*CliContext) ArgumentUint64Slice added in v1.17.0

func (r *CliContext) ArgumentUint64Slice(key string) []uint64

func (*CliContext) ArgumentUintSlice added in v1.17.0

func (r *CliContext) ArgumentUintSlice(key string) []uint

func (*CliContext) Arguments added in v1.0.0

func (r *CliContext) Arguments() []string

func (*CliContext) Ask added in v1.14.0

func (r *CliContext) Ask(question string, option ...console.AskOption) (string, error)

func (*CliContext) Black added in v1.17.0

func (r *CliContext) Black(message string)

func (*CliContext) Blackln added in v1.17.0

func (r *CliContext) Blackln(message string)

func (*CliContext) Choice added in v1.14.0

func (r *CliContext) Choice(question string, choices []console.Choice, option ...console.ChoiceOption) (string, error)

func (*CliContext) Comment added in v1.14.0

func (r *CliContext) Comment(message string)

func (*CliContext) Confirm added in v1.14.0

func (r *CliContext) Confirm(question string, option ...console.ConfirmOption) bool

func (*CliContext) CreateProgressBar added in v1.14.0

func (r *CliContext) CreateProgressBar(total int) console.Progress

func (*CliContext) Deadline added in v1.18.0

func (r *CliContext) Deadline() (deadline time.Time, ok bool)

func (*CliContext) Divider added in v1.17.0

func (r *CliContext) Divider(filler ...string)

func (*CliContext) Done added in v1.18.0

func (r *CliContext) Done() <-chan struct{}

func (*CliContext) Err added in v1.18.0

func (r *CliContext) Err() error

func (*CliContext) Error added in v1.14.0

func (r *CliContext) Error(message string)

func (*CliContext) Green added in v1.17.0

func (r *CliContext) Green(message string)

func (*CliContext) Greenln added in v1.17.0

func (r *CliContext) Greenln(message string)

func (*CliContext) Info added in v1.14.0

func (r *CliContext) Info(message string)

func (*CliContext) Instance added in v1.16.4

func (r *CliContext) Instance() *cli.Command

func (*CliContext) Line added in v1.14.0

func (r *CliContext) Line(message string)

func (*CliContext) MultiSelect added in v1.14.0

func (r *CliContext) MultiSelect(question string, choices []console.Choice, option ...console.MultiSelectOption) ([]string, error)

func (*CliContext) NewLine added in v1.14.0

func (r *CliContext) NewLine(times ...int)

func (*CliContext) Option added in v1.0.0

func (r *CliContext) Option(key string) string

func (*CliContext) OptionBool added in v1.12.0

func (r *CliContext) OptionBool(key string) bool

func (*CliContext) OptionFloat64 added in v1.12.0

func (r *CliContext) OptionFloat64(key string) float64

func (*CliContext) OptionFloat64Slice added in v1.12.0

func (r *CliContext) OptionFloat64Slice(key string) []float64

func (*CliContext) OptionInt added in v1.12.0

func (r *CliContext) OptionInt(key string) int

func (*CliContext) OptionInt64 added in v1.12.0

func (r *CliContext) OptionInt64(key string) int64

func (*CliContext) OptionInt64Slice added in v1.12.0

func (r *CliContext) OptionInt64Slice(key string) []int64

func (*CliContext) OptionIntSlice added in v1.12.0

func (r *CliContext) OptionIntSlice(key string) []int

func (*CliContext) OptionSlice added in v1.12.0

func (r *CliContext) OptionSlice(key string) []string

func (*CliContext) Red added in v1.17.0

func (r *CliContext) Red(message string)

func (*CliContext) Redln added in v1.17.0

func (r *CliContext) Redln(message string)

func (*CliContext) Secret added in v1.14.0

func (r *CliContext) Secret(question string, option ...console.SecretOption) (string, error)

func (*CliContext) Spinner added in v1.14.0

func (r *CliContext) Spinner(message string, option console.SpinnerOption) error

func (*CliContext) Success added in v1.15.0

func (r *CliContext) Success(message string)

func (*CliContext) Table added in v1.18.0

func (r *CliContext) Table(headers []string, rows [][]string, option ...console.TableOption)

func (*CliContext) TwoColumnDetail added in v1.15.0

func (r *CliContext) TwoColumnDetail(first, second string, filler ...rune)

func (*CliContext) Value added in v1.18.0

func (r *CliContext) Value(key any) any

func (*CliContext) Warning added in v1.14.0

func (r *CliContext) Warning(message string)

func (*CliContext) WithProgressBar added in v1.14.0

func (r *CliContext) WithProgressBar(items []any, callback func(any) error) ([]any, error)

func (*CliContext) Yellow added in v1.17.0

func (r *CliContext) Yellow(message string)

func (*CliContext) Yellowln added in v1.17.0

func (r *CliContext) Yellowln(message string)

type ProgressBar added in v1.14.0

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

func NewProgressBar added in v1.14.0

func NewProgressBar(total int) *ProgressBar

func (*ProgressBar) Advance added in v1.14.0

func (r *ProgressBar) Advance(step ...int)

func (*ProgressBar) Finish added in v1.14.0

func (r *ProgressBar) Finish() error

func (*ProgressBar) SetTitle added in v1.14.0

func (r *ProgressBar) SetTitle(message string)

func (*ProgressBar) ShowElapsedTime added in v1.14.0

func (r *ProgressBar) ShowElapsedTime(b ...bool) console.Progress

func (*ProgressBar) ShowTitle added in v1.14.0

func (r *ProgressBar) ShowTitle(b ...bool) console.Progress

func (*ProgressBar) Start added in v1.14.0

func (r *ProgressBar) Start() error

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (r *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (r *ServiceProvider) Register(app foundation.Application)

func (*ServiceProvider) Relationship added in v1.15.12

func (r *ServiceProvider) Relationship() binding.Relationship

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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