gocli

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: BSD-2-Clause Imports: 11 Imported by: 12

README

gocli

Entry point for application

Documentation

Index

Constants

View Source
const (
	ArgumentTypeString = "string"
	ArgumentTypeInt    = "int"
)
View Source
const (
	LogLevelDebug = 1 << iota
	LogLevelInfo
	LogLevelWarn
	LogLevelErr
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	// Get config struct
	GetConfig() interface{}
	// Get full path to config
	GetConfigPath(env string) string
	// Set config struct
	SetConfig(cfg interface{}) Application
	// Start application
	Start(arguments Arguments) IError
	// Init app method
	New(env string, cfg interface{}) Application
	// Behaviour for fatal errors
	FatalError(err error)
	// Get Logger
	GetLogger(level int) Logger
	// Parse console flags
	ParseFlags(args *Arguments)
}

Application class

type ApplicationError

type ApplicationError struct {
	// contains filtered or unexported fields
}

Application Error

func (ApplicationError) AddDetail

func (ae ApplicationError) AddDetail(message string, code int) IError

Interface app error add detail

func (ApplicationError) Error

func (ae ApplicationError) Error() string

Interface error method

func (ApplicationError) GetCode

func (ae ApplicationError) GetCode() int

Interface app error get code

func (ApplicationError) GetDetails

func (ae ApplicationError) GetDetails() []ApplicationErrorDetail

Interface app error get details

func (ApplicationError) GetStack

func (ae ApplicationError) GetStack() []byte

Interface app error get stack

type ApplicationErrorDetail

type ApplicationErrorDetail struct {
	Code    int
	Message string
}

Detailed error

type Argument

type Argument struct {
	Type  string
	Value interface{}
	Label string
}

type Arguments

type Arguments map[string]Argument

Console app arguments

type DNApp

type DNApp struct {
	// contains filtered or unexported fields
}

Dynamic Name Application

func (DNApp) FatalError

func (a DNApp) FatalError(err error)

Fatal error

func (DNApp) GetConfig

func (a DNApp) GetConfig() interface{}

Get config struct

func (DNApp) GetConfigPath

func (a DNApp) GetConfigPath(env string) string

Get full path to config

func (DNApp) GetLogger

func (a DNApp) GetLogger(level int) *logger

Get logger

func (DNApp) New

func (a DNApp) New(env string, config interface{}) Application

Init app

func (DNApp) ParseFlags

func (a DNApp) ParseFlags(args *Arguments)

Parse console arguments

func (DNApp) SetConfig

func (a DNApp) SetConfig(cfg interface{}) Application

Set config struct

func (DNApp) Start

func (a DNApp) Start(arguments Arguments) IError

Start application

type IError added in v0.0.6

type IError interface {
	Error() string
	GetCode() int
	GetStack() []byte
	GetDetails() []ApplicationErrorDetail
	AddDetail(message string, code int) IError
}

Common Error Interface

func NewError

func NewError(message string, code int) IError

New error

func NewErrorF

func NewErrorF(message string, code int, args ...interface{}) IError

New error

type Logger added in v0.0.7

type Logger interface {
	Print(v ...interface{})
	Println(v ...interface{})
	Printf(format string, v ...interface{})

	Info(v ...interface{})
	Infoln(v ...interface{})
	Infof(format string, v ...interface{})

	Warn(v ...interface{})
	Warnln(v ...interface{})
	Warnf(format string, v ...interface{})

	Error(v ...interface{})
	Errorln(v ...interface{})
	Errorf(format string, v ...interface{})
}

func NewLogger

func NewLogger(level int, prefix string, flags int) Logger

New logger

Jump to

Keyboard shortcuts

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