outinject

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 4 Imported by: 1

README

outinject

Documentation

Overview

MIT License

Copyright (c) 2022 Thomas Ziegler, <thomas.zglr@googlemail.com>. All rights reserved.

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MOut

type MOut struct {
	Io          io.ReadWriter // currently used ReadWriter
	NamedWriter string        // if a named write is set, this will be the name
	Parser      OutParser     // used parser
	IsTerminal  bool          // if we cloud detect an terminal support
	Width       int           // the witdth of a terminal, if we have detect a terminal
	Height      int           // same for the height
}

func NewStdout added in v0.0.2

func NewStdout() *MOut

func (*MOut) Err added in v0.0.2

func (m *MOut) Err() *MOut

set stderr as writer

func (*MOut) GetParser added in v0.0.2

func (m *MOut) GetParser() *OutParser

GetParser returns the instance of the parser. can be nil

func (*MOut) Named added in v0.0.2

func (m *MOut) Named(key string) *MOut

sets an named writer if exists. or ignores if not. writer have to be set with SetNamedWriter before.

func (*MOut) Out added in v0.0.2

func (m *MOut) Out(i ...interface{}) (n int, err error)

Out print the formatted content by using fmt.Fprint have the same return values.

func (*MOut) OutLn added in v0.0.2

func (m *MOut) OutLn(i ...interface{}) (n int, err error)

OutLn print the formatted content by using fmt.Fprintln it have the same return values like fmt.Fprintln

func (*MOut) SetNamedWriter added in v0.0.2

func (m *MOut) SetNamedWriter(key string, io io.ReadWriter) *MOut

register or overidde a io.Writer by key-name. also it will be set as the current writer

func (*MOut) SetParser added in v0.0.2

func (m *MOut) SetParser(parser OutParser) *MOut

sets the parser they is responsible for formatting

func (*MOut) Std added in v0.0.2

func (m *MOut) Std() *MOut

set stdout as writer

func (*MOut) ToString added in v0.0.2

func (m *MOut) ToString(i ...interface{}) string

ToString get the formated string, depending on the used formatter

type OutParser

type OutParser interface {
	Parse(i ...interface{}) string // parses all arguments and returns a composed string
	Enable(mo *MOut) bool          // hook to disable or enable some features
}

OutParser is the interface that is used by parsers

type OutputManager added in v0.0.2

type OutputManager interface {
	Std() *MOut                                        // Points to the stdout
	Err() *MOut                                        // Ponints to the Errout
	SetParser(parser OutParser) *MOut                  // sets the current parser
	GetParser() *OutParser                             // returns the surrent parser
	Named(key string) *MOut                            // Like Std() or Err() but for a assigned ReadWriter (SetNamedWriter)
	SetNamedWriter(key string, io io.ReadWriter) *MOut // adds an costume ReadWriter togehter with an name
	ToString(i ...interface{}) string                  // creates an String by using the current Parser
	Out(i ...interface{}) (n int, err error)           // Print the output by using the current Parser and current ReadWriter, without line ending
	OutLn(i ...interface{}) (n int, err error)         // sam as Out() but with line ending
}

type PlainParse added in v0.0.2

type PlainParse struct {
}

func (PlainParse) Enable added in v0.0.2

func (c PlainParse) Enable(mo *MOut) bool

func (PlainParse) Parse added in v0.0.2

func (c PlainParse) Parse(i ...interface{}) string

Jump to

Keyboard shortcuts

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