ui

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var ERROR_PREFIX = color.New(color.Bold, color.FgRed, color.ReverseVideo).Sprint(" ERROR ")
View Source
var InfoPrefix = color.New(color.Bold, color.FgWhite, color.ReverseVideo).Sprint(" INFO ")

InfoPrefix is a colored string for warning level log messages

View Source
var IsCI = !IsTTY || ci.IsCi()

IsCI is true when we appear to be running in a non-interactive context.

View Source
var IsTTY = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())

IsTTY is true when stdout appears to be a tty

View Source
var WARNING_PREFIX = color.New(color.Bold, color.FgYellow, color.ReverseVideo).Sprint(" WARNING ")

Functions

func Bold

func Bold(str string) string

func Dim

func Dim(str string) string

Dim prints out dimmed text

func Rainbow

func Rainbow(text string) string

Rainbow function returns a formated colorized string ready to print it to the shell/terminal

Adapted from go-rainbow Copyright (c) 2017 Raphael Amorim Source: https://github.com/raphamorim/go-rainbow SPDX-License-Identifier: MIT

Types

type BasicUI

type BasicUI struct {
	Reader      io.Reader
	Writer      io.Writer
	ErrorWriter io.Writer
}

BasicUI is an implementation of Ui that just outputs to the given writer. This UI is not threadsafe by default, but you can wrap it in a ConcurrentUi to make it safe.

Inlined from cli.Ui to fuse newlines to lines being logged. This is probably not the optimal way to do it, but it works for now.

func (*BasicUI) Ask

func (u *BasicUI) Ask(query string) (string, error)

Ask implements ui.Cli.Ask for BasicUi

func (*BasicUI) AskSecret

func (u *BasicUI) AskSecret(query string) (string, error)

AskSecret implements ui.Cli.AskSecret for BasicUi

func (*BasicUI) Error

func (u *BasicUI) Error(message string)

Error implements ui.Cli.Error for BasicUi

func (*BasicUI) Info

func (u *BasicUI) Info(message string)

Info implements ui.Cli.Info for BasicUi

func (*BasicUI) Output

func (u *BasicUI) Output(message string)

Output implements ui.Cli.Output for BasicUi

func (*BasicUI) Warn

func (u *BasicUI) Warn(message string)

Warn implements ui.Cli.Warn for BasicUi

type BasicUIFactory

type BasicUIFactory struct {
}

BasicUIFactory provides a method for creating a cli.BasicUi from input, output and error IOs

func (*BasicUIFactory) Build

func (factory *BasicUIFactory) Build(in io.Reader, out io.Writer, err io.Writer) cli.Ui

Build builds a cli.BasicUi from input, output and error IOs

type ColorMode

type ColorMode int
const (
	ColorModeUndefined ColorMode = iota + 1
	ColorModeSuppressed
	ColorModeForced
)

func GetColorModeFromEnv

func GetColorModeFromEnv() ColorMode

type ColoredUIFactory

type ColoredUIFactory struct {
	ColorMode ColorMode
	Base      Factory
}

ColoredUIFactory provides a method for creating a cli.ColoredUi from input, output and error IOs

func (*ColoredUIFactory) Build

func (factory *ColoredUIFactory) Build(in io.Reader, out io.Writer, err io.Writer) cli.Ui

Build builds a cli.ColoredUi from input, output and error IOs

type ConcurrentUIFactory

type ConcurrentUIFactory struct {
	Base Factory
}

ConcurrentUIFactory provides a method for creating a cli.ConcurrentUi from input, output and error IOs

func (*ConcurrentUIFactory) Build

func (factory *ConcurrentUIFactory) Build(in io.Reader, out io.Writer, err io.Writer) cli.Ui

Build builds a cli.ConcurrentUi from input, output and error IOs

type Factory

type Factory interface {
	Build(in io.Reader, out io.Writer, err io.Writer) cli.Ui
}

Factory provides an interface for creating cli.Ui instances from input, output and error IOs

type PrefixedUIFactory

type PrefixedUIFactory struct {
	Base            Factory
	AskPrefix       string
	AskSecretPrefix string
	OutputPrefix    string
	InfoPrefix      string
	ErrorPrefix     string
	WarnPrefix      string
}

PrefixedUIFactory provides a method for creating a cli.PrefixedUi from input, output and error IOs

func (*PrefixedUIFactory) Build

func (factory *PrefixedUIFactory) Build(in io.Reader, out io.Writer, err io.Writer) cli.Ui

Build builds a cli.PrefixedUi from input, output and error IOs

type Spinner

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

Spinner represents an indicator that an asynchronous operation is taking place.

For short operations, less than 4 seconds, display only the spinner with the Start and Stop methods. For longer operations, display intermediate progress events using the Events method.

func NewSpinner

func NewSpinner(w io.Writer) *Spinner

NewSpinner returns a spinner that outputs to w.

func (*Spinner) Start

func (s *Spinner) Start(label string)

Start starts the spinner suffixed with a label.

func (*Spinner) Stop

func (s *Spinner) Stop(label string)

Stop stops the spinner and replaces it with a label.

Directories

Path Synopsis
Package cursor provides functionality to interact with the terminal cursor.
Package cursor provides functionality to interact with the terminal cursor.

Jump to

Keyboard shortcuts

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