common

package
v0.0.0-...-9774daa Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2015 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASCII = []string{"    d8b",
	"     ?88",
	"      88b",
	"      888  d88' d888b8b  ?88,.d88b,?88,.d88b, d888b8b",
	"      888bd8P' d8P' ?88   ?88'  ?88 ?88'  ?88d8P' ?88",
	"     d88888b   88b  ,88b   88b  d8P  88b  d8P88b  ,88b",
	"    d88'  ?88b, ?88P' 88b  888888P'  888888P' ?88P' 88b",
	"                           88P'      88P'",
	"                          d88       d88",
	"                          ?8P       ?8P"}
View Source
var DefaultColorCodes = ColorCodes{
	Black:   []byte{keyEscape, '[', '3', '0', 'm'},
	Red:     []byte{keyEscape, '[', '3', '1', 'm'},
	Green:   []byte{keyEscape, '[', '3', '2', 'm'},
	Yellow:  []byte{keyEscape, '[', '3', '3', 'm'},
	Blue:    []byte{keyEscape, '[', '3', '4', 'm'},
	Magenta: []byte{keyEscape, '[', '3', '5', 'm'},
	Cyan:    []byte{keyEscape, '[', '3', '6', 'm'},
	White:   []byte{keyEscape, '[', '3', '7', 'm'},

	LightGrey:    []byte{keyEscape, '[', '9', '0', 'm'},
	LightRed:     []byte{keyEscape, '[', '9', '1', 'm'},
	LightGreen:   []byte{keyEscape, '[', '9', '2', 'm'},
	LightYellow:  []byte{keyEscape, '[', '9', '3', 'm'},
	LightBlue:    []byte{keyEscape, '[', '9', '4', 'm'},
	LightMagenta: []byte{keyEscape, '[', '9', '5', 'm'},
	LightCyan:    []byte{keyEscape, '[', '9', '6', 'm'},
	LightWhite:   []byte{keyEscape, '[', '9', '7', 'm'},
	Reset:        []byte{keyEscape, '[', '0', 'm'},
}

ANSI colors

Functions

This section is empty.

Types

type ColorCodes

type ColorCodes struct {
	// Foreground colors
	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte

	// Light Foreground colors
	LightGrey, LightRed, LightGreen, LightYellow, LightBlue, LightMagenta, LightCyan, LightWhite []byte

	// Reset all attributes
	Reset []byte
}

type ResponseWriter

type ResponseWriter struct {
	Colors ColorCodes
	Writer io.Writer
}

ResponseWriter writes data and status codes to the client

func (*ResponseWriter) Fail

func (r *ResponseWriter) Fail(code StatusCode, format string, args ...interface{})

Fail writes the error status code to the Writer

func (*ResponseWriter) Success

func (r *ResponseWriter) Success(code StatusCode, format string, args ...interface{})

Success writes the status code to the Writer

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(data []byte) (int, error)

Write is a pass through function into the underlying Writer

type StatusCode

type StatusCode int
const (
	OK StatusCode = iota + 2000
	NamespaceAlreadyExists
	UserAlreadyExists
)

Success codes

const (
	InternalServerError StatusCode = iota + 5000
	InvalidStatementType
	NamespaceDoesNotExist
	UserDoesNotExist
	CreateNamespaceError
)

Error codes

const (
	Unauthorized StatusCode = iota + 4000
)

Authentication related error codes

type Terminal

type Terminal interface {
	GetPrompt() string
	ResetPrompt()
	SetPrompt(p string)
}

Terminal wraps an ssh.Terminal in order to supply an interface for easy mocking

func NewTerminal

func NewTerminal(term *terminal.Terminal, prompt string) Terminal

NewTerminal creates a new terminal wrapper

Jump to

Keyboard shortcuts

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