gocli

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: BSD-2-Clause Imports: 17 Imported by: 12

README

gocli

Entry point for application

Documentation

Index

Constants

View Source
const (
	ArgumentTypeString = "string"
	ArgumentTypeInt    = "int"
	ArgumentTypeUint   = "uint"
	ArgumentTypeBool   = "bool"
)
View Source
const (
	CommandPrefix   = "-"
	CommandAssignee = "="
)
View Source
const (
	LogLevelDebug = 1 << iota
	LogLevelInfo
	LogLevelWarn
	LogLevelErr
)
View Source
const (
	CommandSessionHost = "localhost"
	CommandSessionType = "tcp"
)

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(port string, callback func(command Command)) 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
	Name  string
}

Argument

func (Argument) GetBool added in v0.3.1

func (a Argument) GetBool() bool

Get bool value of argument

func (Argument) GetInt added in v0.1.3

func (a Argument) GetInt() int64

Get int value of argument

func (Argument) GetString added in v0.1.3

func (a Argument) GetString() string

Get string value of argument

func (Argument) GetUnit added in v0.3.1

func (a Argument) GetUnit() uint64

Get int value of argument

type Arguments

type Arguments map[string]Argument

Console app arguments

type Command added in v0.4.0

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

Command is an argument list

func ParseCommand added in v0.4.0

func ParseCommand(command []byte) Command

Parse command

func (Command) Arguments added in v0.4.0

func (c Command) Arguments() []Argument

UnBind connection

func (*Command) BindConnection added in v0.4.0

func (c *Command) BindConnection(conn net.Conn)

Bind connection to command

func (Command) GetOrigin added in v0.4.0

func (c Command) GetOrigin() string

Get origin command

func (Command) Result added in v0.4.0

func (c Command) Result(result []byte) porterr.IError

Result of command to connection

func (*Command) UnbindConnection added in v0.4.0

func (c *Command) UnbindConnection()

UnBind connection

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(port string, callback func(command Command)) 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