gocli

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 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) porterr.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 Argument

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

Argument

func (Argument) GetInt added in v0.1.3

func (a Argument) GetInt() int64

Get int value

func (Argument) GetString added in v0.1.3

func (a Argument) GetString() string

Get string

type Arguments

type Arguments map[string]Argument

Console app arguments

type DNApp

type DNApp struct {
	ConfigPath string
	// 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) porterr.IError

Start application

type Logger added in v0.0.7

type Logger interface {
	GetLevel() int

	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