commander

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GlobalOptions = make(map[string]*Optional)
)

Functions

func SetDefaultChannel

func SetDefaultChannel(channel string)

func SetDefaultDebugMode

func SetDefaultDebugMode(mode int)

Types

type Command

type Command struct {
	Logger
	CommandName string
	Positionals []string
	Optionals   map[string]*Optional
	Values      map[string]string
	Usage       string
	Description string
	// contains filtered or unexported fields
}

Command : Interface describing properties held by command

func (*Command) BuildHelp

func (c *Command) BuildHelp(helpTemplate string) string

func (*Command) GetBool

func (c *Command) GetBool(key string, defaultValue bool) bool

func (*Command) GetFloat32 added in v0.0.1

func (c *Command) GetFloat32(key string, defaultValue float32) float32

func (*Command) GetFloat64 added in v0.0.1

func (c *Command) GetFloat64(key string, defaultValue float64) float64

func (*Command) GetInt added in v0.0.1

func (c *Command) GetInt(key string, defaultValue int) int

func (*Command) GetString added in v0.0.1

func (c *Command) GetString(key string, defaultValue string) string

func (*Command) GetUint added in v0.0.1

func (c *Command) GetUint(key string, defaultValue uint) uint

func (*Command) GetUsage

func (c *Command) GetUsage() string

func (*Command) Help

func (c *Command) Help()

func (*Command) Init

func (c *Command) Init()

Init : Here to prevent Logger.Init from overriding a command's Init method

func (*Command) Name

func (c *Command) Name() string

func (*Command) RegisterOptional

func (c *Command) RegisterOptional(option string, value string)

func (*Command) RegisterPositionals

func (c *Command) RegisterPositionals(positionals []string)

func (*Command) SetName

func (c *Command) SetName(name string)

func (*Command) Space

func (c *Command) Space(key string) string

type Commandable

type Commandable interface {
	Run()
	Init()
	Help()
	Name() string
	GetUsage() string
	SetName(string)
	RegisterOptional(string, string)
	RegisterPositionals([]string)
}

type Commander

type Commander struct {
	Logger

	Ready func()
	// contains filtered or unexported fields
}

Commander : Command line parser

func (*Commander) Init

func (c *Commander) Init(programName string)

func (*Commander) Parse

func (c *Commander) Parse(cmds []string)

Parse : Parses command line arguments

func (*Commander) Register

func (c *Commander) Register(name string, cmd Commandable)

func (*Commander) RegisterCommands

func (c *Commander) RegisterCommands(cmds map[string]Commandable)

func (*Commander) RegisterOption

func (c *Commander) RegisterOption(name string, listener *Listener)

type Listener

type Listener struct {
	Option *Optional
	Method func(interface{})
}

type Logger

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

Logger : This is the logging utility class

func (*Logger) DebugLog

func (l *Logger) DebugLog(params ...interface{})

func (*Logger) DebugLogString

func (l *Logger) DebugLogString(params ...string)

func (*Logger) Error

func (l *Logger) Error(params ...string)

func (*Logger) Fatal

func (l *Logger) Fatal(params ...string)

func (*Logger) FatalWithCode

func (l *Logger) FatalWithCode(code int, params ...string)

func (*Logger) Init

func (l *Logger) Init(channel string, debug int)

func (*Logger) Log

func (l *Logger) Log(params ...interface{})

func (*Logger) LogString

func (l *Logger) LogString(params ...string)

type Optional

type Optional struct {
	Type        string
	Description string
}

Jump to

Keyboard shortcuts

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