tui

package
v1.54.18 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = TagPrinter{
		Prefix: addPrefix("debug", Colors.White, Colors.TextMuted),
	}
	Error = TagPrinter{
		Prefix: addPrefix("error", Colors.White, Colors.Red),
	}
	Warning = TagPrinter{
		Prefix: addPrefix("warning", Colors.Black, Colors.Yellow),
	}
)
View Source
var Docker = &Dependency{
	name:    "Docker",
	command: "docker version",
	assist: func() error {
		return fmt.Errorf("docker is required to run this command. For installation instructions see: https://docs.docker.com/engine/install/")
	},
}
View Source
var DockerBuildx = &Dependency{
	name:    "Docker Buildx",
	command: "docker buildx version",
	assist: func() error {
		return fmt.Errorf("docker buildx is required to run this command. For installation instructions see: https://github.com/docker/buildx")
	},
}
View Source
var KeyMap = DefaultKeyMap{
	Enter: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "submit input"),
	),
	Quit: key.NewBinding(
		key.WithKeys("esc", "ctrl+c"),
		key.WithHelp("esc", "exit"),
	),
	Up: key.NewBinding(
		key.WithKeys("up"),
		key.WithHelp("↑", "up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down"),
		key.WithHelp("↓", "down"),
	),
}

KeyMap contains our standard keybinding for CLI input

View Source
var Pulumi = &Dependency{
	name:    "Pulumi",
	command: "pulumi version",
	assist: func() error {
		var resp bool
		_ = survey.AskOne(&survey.Confirm{
			Message: fmt.Sprintf("Pulumi is required by %s but is not installed, would you like to install it?", "command"),
			Default: false,
		}, &resp)

		if !resp {
			return fmt.Errorf("pulumi is required to run this command. For installation instructions see: https://www.pulumi.com/docs/get-started/install/")
		}

		var installErr error
		platform := runtime.GOOS
		switch platform {
		case "darwin", "linux":
			cmd := exec.Command("sh", "-c", "curl -fsSL https://get.pulumi.com | sh")
			cmd.Stdout = os.Stdout
			installErr = cmd.Run()
		case "windows":
			cmd := exec.Command("powershell", "-NoProfile", "-InputFormat", "None", "-ExecutionPolicy", "Bypass", "-Command", "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://get.pulumi.com/install.ps1'))")
			cmd.Stdout = os.Stdout
			installErr = cmd.Run()
			if installErr == nil {
				cmd := exec.Command("powershell", "SET", "PATH='%PATH%;%USERPROFILE%\\.pulumi\\bin'")
				cmd.Stdout = os.Stdout
				installErr = cmd.Run()
			}
		default:
			installErr = fmt.Errorf("platform %s not supported", platform)
		}

		return installErr
	},
}

Functions

func AddDependencyCheck

func AddDependencyCheck(cmd *cobra.Command, deps ...*Dependency) *cobra.Command

AddDependencyCheck - Wraps a cobra command with a pre-run that will check for dependencies

func CheckErr

func CheckErr(err error)

func DebugColors

func DebugColors() string

DebugColors returns the entire color palette as a string

Use for testing various terminals to confirm output

func IsTerminal

func IsTerminal() bool

IsTerminal returns true if the current process is running in an interactive terminal

Types

type ColorPalette

ColorPalette of standard CLI UI colors

var Colors *ColorPalette = &ColorPalette{
	White:  lipgloss.CompleteAdaptiveColor{Light: white, Dark: white},
	Gray:   lipgloss.CompleteAdaptiveColor{Light: gray, Dark: gray},
	Black:  lipgloss.CompleteAdaptiveColor{Light: black, Dark: black},
	Red:    lipgloss.CompleteAdaptiveColor{Light: red, Dark: red},
	Orange: lipgloss.CompleteAdaptiveColor{Light: orange, Dark: orange},
	Yellow: lipgloss.CompleteAdaptiveColor{Light: yellow, Dark: yellow},
	Green:  lipgloss.CompleteAdaptiveColor{Light: green, Dark: green},
	Teal:   lipgloss.CompleteAdaptiveColor{Light: teal, Dark: teal},
	Blue:   lipgloss.CompleteAdaptiveColor{Light: blue, Dark: blue},
	Purple: lipgloss.CompleteAdaptiveColor{Light: purple, Dark: purple},
	Text: lipgloss.CompleteAdaptiveColor{
		Light: black,
		Dark:  white,
	},
	TextMuted: lipgloss.CompleteAdaptiveColor{
		Light: lipgloss.CompleteColor{TrueColor: "#4E4E4E", ANSI256: "242", ANSI: "8"},
		Dark:  lipgloss.CompleteColor{TrueColor: "#9E9E9E", ANSI256: "249", ANSI: "7"},
	},
	TextHighlight: lipgloss.CompleteAdaptiveColor{
		Light: blue,
		Dark:  purple,
	},
	TextActive: lipgloss.CompleteAdaptiveColor{
		Light: blue,
		Dark:  blue,
	},
}

Colors contains our standard UI colors for CLI output

type DefaultKeyMap

type DefaultKeyMap struct {
	Enter key.Binding
	Quit  key.Binding
	Up    key.Binding
	Down  key.Binding
}

type Dependency

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

type TagPrinter added in v1.36.6

type TagPrinter struct {
	Prefix string
}

func (*TagPrinter) Printfln added in v1.36.6

func (t *TagPrinter) Printfln(message string, a ...interface{})

func (*TagPrinter) Println added in v1.36.6

func (t *TagPrinter) Println(message string)

Directories

Path Synopsis
commands
components

Jump to

Keyboard shortcuts

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