printer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

*

  • Copyright 2021 Napptive *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • https://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

View Source
const (
	// MinWidth is the minimal cell width including any padding.
	MinWidth = 8
	// TabWidth is the width of tab characters (equivalent number of spaces)
	TabWidth = 4
	// Padding added to a cell before computing its width
	Padding = 4
	// PaddingChar with the ASCII char used for padding
	PaddingChar = ' '
	// TabWriterFlags with the formatting options.
	TabWriterFlags = 0
)
View Source
const ApplicationListTemplate = `APPLICATION	NAME
{{range $other, $app := .Applications}}{{fromApplicationSummary $app}}{{end}}`
View Source
const InfoAppResponseTemplate = `` /* 477-byte string literal not displayed */

InfoAppResponseTemplate with the table representation of an InfoAppResponse.

View Source
const OpResponseTemplate = `STATUS	INFO
{{.StatusName}}	{{.UserInfo}}
`

OpResponseTemplate with the table representation of an OpResponse.

View Source
const SummaryResponseTemplate = `NAMESPACES	APPLICATIONS	TAGS
{{.NumNamespaces}}	{{.NumApplications}}	{{.NumTags}}
`

Variables

This section is empty.

Functions

func GetTemplate

func GetTemplate(result interface{}) (*string, error)

GetTemplate returns a template to print an arbitrary structure in table format.

Types

type JSONPrinter

type JSONPrinter struct {
}

JSONPrinter structure with the implementation required to print as JSON a given result.

func (*JSONPrinter) Print

func (jp *JSONPrinter) Print(result interface{}) error

Print the result.

type NoPrinter

type NoPrinter struct {
}

NoPrinter structure with the implementation required to print an empty result. Sometimes we could not to print the result

func (*NoPrinter) Print

func (jp *NoPrinter) Print(result interface{}) error

Print the result (empty result)

type ResultPrinter

type ResultPrinter interface {
	// Print the result.
	Print(result interface{}) error
}

ResultPrinter defines the operations that a printer must define. Multiple printer are offered depending on the desired output format.

func GetPrinter

func GetPrinter(printerType string) (ResultPrinter, error)

GetPrinter creates a ResultPrinter attending to the user preferences.

func NewJSONPrinter

func NewJSONPrinter() (ResultPrinter, error)

NewJSONPrinter build a new ResultPrinter whose output is the JSON representation of the object.

func NewNoPrinter

func NewNoPrinter() (ResultPrinter, error)

NewNoPrinter build a new NoPrinter.

func NewTablePrinter

func NewTablePrinter() (ResultPrinter, error)

NewTablePrinter builds a new ResultPrinter whose output is a human readable table-like representation of the object.

type TablePrinter

type TablePrinter struct {
}

TablePrinter structure with the implementation required to print in a human readable table format a given result.

func (*TablePrinter) Print

func (tp *TablePrinter) Print(result interface{}) error

Print the result.

Jump to

Keyboard shortcuts

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