termtext

package module
v0.2.11-0...-bab5264 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ScreenNoColorDefaultKey = "termtextNoColor"      // No Color profile
	ScreenDarkDefaultKey    = "termtextDarkDefault"  // Dark Profile
	ScreenLightDefaultKey   = "termtextLightDefault" // Light Profile
)

Values

View Source
const JSONDisplayKey = "Termtext.JSONDisplay" // bool

JSONDisplayKey controls output. If set only JSON is displayed for renders which have response objects. For example, in a yaml configuration file you can set: Termtext:

JSONDisplay: True
View Source
const (
	ScreenProfileKey = "Termtext.screenProfile" // Viper Key for profile name - string
)

Variables

Variables

This section is empty.

Functions

func Describe

func Describe(d Describable, resp *http.Response, err error)

Describe provides detailed output on the object.

func Error

func Error(err error) string

Error formats an error string.

func HTTPDisplay

func HTTPDisplay(resp *http.Response, err error)

HTTPDisplay - This is for the HTTP direct commands.

func InitTerm

func InitTerm()

InitTerm sets profile defaults from viper.

func List

func List(d Listable, resp *http.Response, err error)

List and Describe display their objects by calling render, but first checking that an object is there. If not they send along an empty function for the descoroator to call.

func LocString

func LocString(d int) string

LocString string for function and file location of depth d. 0 is depth of the function calling LocString, 1 is the callers caller etc.

func Pef

func Pef()

Pef is an entry tracing printout to stdout. It will print the word Enter, a funciton name, file name and line number. It is designed to be used as the first line of a function, perhaps bracketed by a debug check.

func Pxf

func Pxf()

Pxf is an exit tracing pritout to stdout. It will print out the word exit, a function name, file anda line number. It is designed to be used just after a call to Pef() with a defer. Pef() defer Pxf()

Types

type ColorSprintfFunc

type ColorSprintfFunc func(string, ...interface{}) string

ColorSprintfFunc use this with github.com/juju/ansi term to get a TabWriter that works with color.

I think I like this better than setting up function calls that map to a wrapper around the function call off of ScreenProfile eg.

func Title(s string, args ...interface{}) string {
  ScreenProfile.Title( ...... )
}

It's true the set up is more expensive, but it does remove a function call from the execution path ......

These are used to surround strings with color. e.g. fmt.Printf(t.Title("This is a title")) or fmt.Printf("%s: %s.", t.Alert("Houston we have a problem"), t.Text("is not what was actually said"))

type Describable

type Describable interface {
	Describe()
}

Describable supports Describe()

type Listable

type Listable interface {
	List()
}

Listable suppots List()

type Message

type Message struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

Message is a simple struct to pull out JSON that is often embedded in error returns.

type Profile

type Profile struct {
	Name, Key                  string           // Name for display, Key for dictionary and viper
	Title, SubTitle, Text      ColorSprintfFunc // Basic text formating
	Info, Highlight            ColorSprintfFunc // Some semantic formats
	Success, Warn, Fail, Alert ColorSprintfFunc // Alert style formats.
}

type ProfileList

type ProfileList []ProfileList

Jump to

Keyboard shortcuts

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