Documentation ¶
Overview ¶
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: MIT
Copyright (c) 2019 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func EnvColorDisabled() bool
- func EnvColorForced() bool
- func Is256ColorSupported() bool
- func IsTrueColorSupported() bool
- func NewNoTTYReader(r io.ReadCloser) *fdReader
- func NewNoTTYWriter(w io.WriteCloser) *fdWriter
- func WithIOStreams(ctx context.Context, iostreams *IOStreams) context.Context
- type ColorScheme
- func (c *ColorScheme) Blue(t string) string
- func (c *ColorScheme) Bluef(t string, args ...interface{}) string
- func (c *ColorScheme) Bold(t string) string
- func (c *ColorScheme) Boldf(t string, args ...interface{}) string
- func (c *ColorScheme) ColorFromString(s string) func(string) string
- func (c *ColorScheme) Cyan(t string) string
- func (c *ColorScheme) CyanBold(t string) string
- func (c *ColorScheme) Cyanf(t string, args ...interface{}) string
- func (c *ColorScheme) FailureIcon() string
- func (c *ColorScheme) FailureIconWithColor(colo func(string) string) string
- func (c *ColorScheme) Gray(t string) string
- func (c *ColorScheme) Grayf(t string, args ...interface{}) string
- func (c *ColorScheme) Green(t string) string
- func (c *ColorScheme) Greenf(t string, args ...interface{}) string
- func (c *ColorScheme) HexToRGB(hex string, x string) string
- func (c *ColorScheme) Magenta(t string) string
- func (c *ColorScheme) Magentaf(t string, args ...interface{}) string
- func (c *ColorScheme) Red(t string) string
- func (c *ColorScheme) Redf(t string, args ...interface{}) string
- func (c *ColorScheme) SprintFunc(s string) func(a ...interface{}) string
- func (c *ColorScheme) SuccessIcon() string
- func (c *ColorScheme) SuccessIconWithColor(colo func(string) string) string
- func (c *ColorScheme) WarningIcon() string
- func (c *ColorScheme) Yellow(t string) string
- func (c *ColorScheme) Yellowf(t string, args ...interface{}) string
- type ErrClosedPagerPipe
- type IOStreams
- func (s *IOStreams) CanPrompt() bool
- func (s *IOStreams) ColorEnabled() bool
- func (s *IOStreams) ColorScheme() *ColorScheme
- func (s *IOStreams) ColorSupport256() bool
- func (s *IOStreams) DetectTerminalTheme()
- func (s *IOStreams) EnableVirtualTerminalProcessing() error
- func (s *IOStreams) GetNeverPrompt() bool
- func (s *IOStreams) GetPager() string
- func (s *IOStreams) HasTrueColor() bool
- func (s *IOStreams) IsStderrTTY() bool
- func (s *IOStreams) IsStdinTTY() bool
- func (s *IOStreams) IsStdoutTTY() bool
- func (s *IOStreams) ReadUserFile(fn string) ([]byte, error)
- func (s *IOStreams) RefreshScreen()
- func (s *IOStreams) SetAlternateScreenBufferEnabled(enabled bool)
- func (s *IOStreams) SetColorEnabled(colorEnabled bool)
- func (s *IOStreams) SetIn(in fileReader)
- func (s *IOStreams) SetNeverPrompt(v bool)
- func (s *IOStreams) SetOut(out fileWriter)
- func (s *IOStreams) SetPager(cmd string)
- func (s *IOStreams) SetStderrTTY(isTTY bool)
- func (s *IOStreams) SetStdinTTY(isTTY bool)
- func (s *IOStreams) SetStdoutTTY(isTTY bool)
- func (s *IOStreams) StartAlternateScreenBuffer()
- func (s *IOStreams) StartPager() error
- func (s *IOStreams) StartProgressIndicator()
- func (s *IOStreams) StartProgressIndicatorWithLabel(label string)
- func (s *IOStreams) StopAlternateScreenBuffer()
- func (s *IOStreams) StopPager()
- func (s *IOStreams) StopProgressIndicator()
- func (s *IOStreams) TempFile(dir, pattern string) (*os.File, error)
- func (s *IOStreams) TerminalTheme() string
- func (s *IOStreams) TerminalWidth() int
- type Terminal
Constants ¶
const DefaultWidth = 80
Variables ¶
var ( // G is an alias for FromContext. // // We may want to define this locally to a package to get package tagged // iostreams. G = FromContext // L is the system IO stream. IO = System() )
Functions ¶
func EnvColorDisabled ¶
func EnvColorDisabled() bool
func EnvColorForced ¶
func EnvColorForced() bool
func Is256ColorSupported ¶
func Is256ColorSupported() bool
func IsTrueColorSupported ¶
func IsTrueColorSupported() bool
func NewNoTTYReader ¶ added in v0.4.2
func NewNoTTYReader(r io.ReadCloser) *fdReader
func NewNoTTYWriter ¶ added in v0.4.2
func NewNoTTYWriter(w io.WriteCloser) *fdWriter
Types ¶
type ColorScheme ¶
type ColorScheme struct {
// contains filtered or unexported fields
}
func NewColorScheme ¶
func NewColorScheme(enabled, is256enabled bool, trueColor bool) *ColorScheme
func (*ColorScheme) Blue ¶
func (c *ColorScheme) Blue(t string) string
func (*ColorScheme) Bluef ¶
func (c *ColorScheme) Bluef(t string, args ...interface{}) string
func (*ColorScheme) Bold ¶
func (c *ColorScheme) Bold(t string) string
func (*ColorScheme) Boldf ¶
func (c *ColorScheme) Boldf(t string, args ...interface{}) string
func (*ColorScheme) ColorFromString ¶
func (c *ColorScheme) ColorFromString(s string) func(string) string
func (*ColorScheme) Cyan ¶
func (c *ColorScheme) Cyan(t string) string
func (*ColorScheme) CyanBold ¶
func (c *ColorScheme) CyanBold(t string) string
func (*ColorScheme) Cyanf ¶
func (c *ColorScheme) Cyanf(t string, args ...interface{}) string
func (*ColorScheme) FailureIcon ¶
func (c *ColorScheme) FailureIcon() string
func (*ColorScheme) FailureIconWithColor ¶
func (c *ColorScheme) FailureIconWithColor(colo func(string) string) string
func (*ColorScheme) Gray ¶
func (c *ColorScheme) Gray(t string) string
func (*ColorScheme) Grayf ¶
func (c *ColorScheme) Grayf(t string, args ...interface{}) string
func (*ColorScheme) Green ¶
func (c *ColorScheme) Green(t string) string
func (*ColorScheme) Greenf ¶
func (c *ColorScheme) Greenf(t string, args ...interface{}) string
func (*ColorScheme) Magenta ¶
func (c *ColorScheme) Magenta(t string) string
func (*ColorScheme) Magentaf ¶
func (c *ColorScheme) Magentaf(t string, args ...interface{}) string
func (*ColorScheme) Red ¶
func (c *ColorScheme) Red(t string) string
func (*ColorScheme) Redf ¶
func (c *ColorScheme) Redf(t string, args ...interface{}) string
func (*ColorScheme) SprintFunc ¶
func (c *ColorScheme) SprintFunc(s string) func(a ...interface{}) string
SprintFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprint(). Useful to put into or mix into other string. Windows users should use this in conjunction with color.Output, example:
put := New(FgYellow).SprintFunc() fmt.Fprintf(color.Output, "This is a %s", put("warning"))
func (*ColorScheme) SuccessIcon ¶
func (c *ColorScheme) SuccessIcon() string
func (*ColorScheme) SuccessIconWithColor ¶
func (c *ColorScheme) SuccessIconWithColor(colo func(string) string) string
func (*ColorScheme) WarningIcon ¶
func (c *ColorScheme) WarningIcon() string
func (*ColorScheme) Yellow ¶
func (c *ColorScheme) Yellow(t string) string
func (*ColorScheme) Yellowf ¶
func (c *ColorScheme) Yellowf(t string, args ...interface{}) string
type ErrClosedPagerPipe ¶
type ErrClosedPagerPipe struct {
// contains filtered or unexported fields
}
ErrClosedPagerPipe is the error returned when writing to a pager that has been closed.
type IOStreams ¶
type IOStreams struct { In fileReader Out fileWriter ErrOut io.Writer TempFileOverride *os.File // contains filtered or unexported fields }
func FromContext ¶ added in v0.2.0
FromContext returns the logger kraftkit in the context, or an inert logger that will not log anything.
func (*IOStreams) ColorEnabled ¶
func (*IOStreams) ColorScheme ¶
func (s *IOStreams) ColorScheme() *ColorScheme
func (*IOStreams) ColorSupport256 ¶
func (*IOStreams) DetectTerminalTheme ¶
func (s *IOStreams) DetectTerminalTheme()
DetectTerminalTheme is a utility to call before starting the output pager so that the terminal background can be reliably detected.
func (*IOStreams) EnableVirtualTerminalProcessing ¶
func (*IOStreams) GetNeverPrompt ¶
func (*IOStreams) HasTrueColor ¶
func (*IOStreams) IsStderrTTY ¶
func (*IOStreams) IsStdinTTY ¶
func (*IOStreams) IsStdoutTTY ¶
func (*IOStreams) RefreshScreen ¶ added in v0.4.2
func (s *IOStreams) RefreshScreen()
func (*IOStreams) SetAlternateScreenBufferEnabled ¶ added in v0.4.2
func (*IOStreams) SetColorEnabled ¶
func (*IOStreams) SetNeverPrompt ¶
func (*IOStreams) SetStderrTTY ¶
func (*IOStreams) SetStdinTTY ¶
func (*IOStreams) SetStdoutTTY ¶
func (*IOStreams) StartAlternateScreenBuffer ¶ added in v0.4.2
func (s *IOStreams) StartAlternateScreenBuffer()
func (*IOStreams) StartPager ¶
func (*IOStreams) StartProgressIndicator ¶
func (s *IOStreams) StartProgressIndicator()
func (*IOStreams) StartProgressIndicatorWithLabel ¶
func (*IOStreams) StopAlternateScreenBuffer ¶ added in v0.4.2
func (s *IOStreams) StopAlternateScreenBuffer()
func (*IOStreams) StopProgressIndicator ¶
func (s *IOStreams) StopProgressIndicator()
func (*IOStreams) TerminalTheme ¶
TerminalTheme returns "light", "dark", or "none" depending on the background color of the terminal.
func (*IOStreams) TerminalWidth ¶
TerminalWidth returns the width of the terminal that controls the process