managers

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package managers implements support for command management.

Index

Constants

View Source
const (
	ArgumentsHelp   = "help"
	ArgumentsScript = "go run main.go"
)
View Source
const (
	Version = "3.0.0"
)

Variables

View Source
var (
	ArgumentsRegexOption        = regexp.MustCompile(`^-`)
	ArgumentsRegexOptionName    = regexp.MustCompile(`^(-+)([a-zA-Z0-9][_a-zA-Z0-9-]*)$`)
	ArgumentsRegexOptionPairs   = regexp.MustCompile(`^-+([a-zA-Z0-9][_a-zA-Z0-9-]*)=(.*)$`)
	ArgumentsRegexScriptBinary  = regexp.MustCompile(`^\./[_a-zA-Z0-9-]+$`)
	ArgumentsRegexScriptWorking = regexp.MustCompile(`^[_a-zA-Z0-9-]+$`)
)
View Source
var (
	ValueTypeText = map[ValueType]string{
		ValueTypeBoolean: "boolean",
		ValueTypeFloat:   "float",
		ValueTypeInteger: "integer",
		ValueTypeString:  "string",
	}
)

Functions

This section is empty.

Types

type Arguments

type Arguments interface {
	Get(key string) string
	GetHelpSelector() string
	GetMapper() map[string]string
	GetScript() string
	GetSelector() string
	Has(key string) bool
	Parse(ss ...string) error
}

Arguments operation interface.

func NewArguments

func NewArguments() Arguments

type Command

type Command interface {
	AddOption(opts ...Option) error
	GetDescription() string
	GetHidden() bool
	GetName() string
	GetOption(key string) Option
	GetOptions() map[string]Option
	Run(manager Manager, arguments Arguments) error
	SetDescription(s string) Command
	SetHandler(handler CommandHandler) Command
	SetHidden(b bool) Command
}

Command operation interface.

func NewCommand

func NewCommand(name string) Command

type CommandHandler

type CommandHandler func(manager Manager, arguments Arguments) error

CommandHandler callable handler on command.

type Manager

type Manager interface {
	AddCommand(c Command) error
	GetCommand(key string) Command
	GetCommands() map[string]Command
	GetDescription() string
	Run(a Arguments) error
	RunTerminal() error
	SetDescription(s string) Manager
}

Manager operation interface.

func NewManager

func NewManager() Manager

type Mode

type Mode int
const (
	ModeOptional Mode = iota
	ModeRequired
)

type Option

type Option interface {
	Assign(s string) error
	Assigned() bool
	GetDescription() string
	GetLabel() string
	GetName() string
	GetShortName() string
	SetDefault(v interface{}) Option
	SetDescription(ss ...string) Option
	SetMode(m Mode) Option
	SetShortName(b byte) Option
	SetValueType(vt ValueType) Option
	ToBool() (bool, error)
	ToFloat() (float64, error)
	ToInt() (int64, error)
	ToString() (string, error)
	Validate() error
}

Option operation interface.

func NewOption

func NewOption(name string) Option

type OutputManager

type OutputManager interface {
	Map(keys map[string]interface{}, desc string)
}

OutputManager manager interface.

var (
	// Output
	// manager instance.
	Output OutputManager
)

type ValueType

type ValueType int
const (
	ValueTypeString ValueType = iota
	ValueTypeBoolean
	ValueTypeFloat
	ValueTypeInteger
	ValueTypeNull
)

Jump to

Keyboard shortcuts

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