abstract

package
v0.0.0-...-e732ebd Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeSettings

func DeserializeSettings(bytes []byte, settings *Settings) error

func RegisterAction

func RegisterAction(Action ActionOps)

func SaveSettings

func SaveSettings(settings Settings) error

Types

type Action

type Action struct {
	Parameters  []Parameter `yaml:"parameters"`
	Name        string      `yaml:"name"`
	Command     string      `yaml:"command"`
	Description string      `yaml:"description"`
	Usage       string      `yaml:"usage"`
}

* Action structure, used for defining action data

type ActionImpl

type ActionImpl struct {
	Action
	InProgress bool
	Success    bool
	Message    string
	Parser     ArgumentParser
	Executor   Command
}

func (*ActionImpl) AcquireValues

func (c *ActionImpl) AcquireValues() bool

func (*ActionImpl) Execute

func (c *ActionImpl) Execute(logChannel chan string) bool

func (*ActionImpl) GetCommand

func (c *ActionImpl) GetCommand() string

func (*ActionImpl) GetExitCode

func (c *ActionImpl) GetExitCode() int

func (*ActionImpl) GetLastMessage

func (c *ActionImpl) GetLastMessage() string

func (*ActionImpl) GetName

func (c *ActionImpl) GetName() string

func (*ActionImpl) GetUsage

func (c *ActionImpl) GetUsage() string

func (ActionImpl) Init

func (c ActionImpl) Init() bool

func (*ActionImpl) IsInProgress

func (c *ActionImpl) IsInProgress() bool

func (ActionImpl) Reset

func (c ActionImpl) Reset() bool

func (*ActionImpl) SetArgumentParser

func (c *ActionImpl) SetArgumentParser(parser ArgumentParser)

func (*ActionImpl) SetExecutor

func (c *ActionImpl) SetExecutor(command Command)

type ActionOps

type ActionOps interface {
	/*
	*	Init method
	* Initialise Action to work
	 */
	Init() bool
	/*
	*	Reset method
	* Reset Action for next work
	 */
	Reset() bool
	/*
	*	Execute method
	* Execute Action accordingly to parameters
	* Return execution start/complete status
	 */
	Execute(chan string) bool
	/*
	*	IsInProgress method
	* Return execution progress state
	 */
	IsInProgress() bool
	/*
	*	GetCommand method
	* Return command name
	 */
	GetCommand() string
	/*
	*	GetName method
	* Return command descriptive name
	 */
	GetName() string
	/*
	*	GetUsage method
	* Return command usage sample
	 */
	GetUsage() string
	/*
	*	AcquireValues method
	* Return flag if parameters are satisfied
	 */
	AcquireValues() bool
	/*
	*	GetExitCode method
	* Return execution exit code (0 - ok)
	 */
	GetExitCode() int
	/*
	*	GetLastMessage method
	* Return operation message or error message
	 */
	GetLastMessage() string
	/*
	*	SetArgumentParser method
	* Set Specific Action argument parser
	 */
	SetArgumentParser(ArgumentParser)
	/*
	*	SetArgumentParser method
	* Set Specific Action argument parser
	 */
	SetExecutor(Command)
}

* ActionOps interface, defining abstract Action Operations

type ActionRegistry

type ActionRegistry struct {
	Actions []ActionOps
}

* ActionRegistry structure, used for collecting plugins

var ActiveActionRegistry ActionRegistry = ActionRegistry{}

func GetActionRegistry

func GetActionRegistry() *ActionRegistry

func (*ActionRegistry) Add

func (r *ActionRegistry) Add(a ActionOps)

* ActionRegistry Add method, add a single action to registry

func (*ActionRegistry) AddMany

func (r *ActionRegistry) AddMany(a []ActionOps)

* ActionRegistry AddMany method, add a multiple actions to registry

func (*ActionRegistry) ElementAt

func (r *ActionRegistry) ElementAt(index int) ActionOps

* ActionRegistry ElementAt method, return one action in registry at index or nil

func (*ActionRegistry) GetActions

func (r *ActionRegistry) GetActions() []ActionOps

* ActionRegistry GetActions method, return all actions in registry

func (*ActionRegistry) Size

func (r *ActionRegistry) Size() int

* ActionRegistry Size method, return number of actions in registry

type ArgumentParser

type ArgumentParser interface {
	Validate() bool
	Parse() []interface{}
}

type Command

type Command interface {
	Execute(*ActionImpl, []interface{}, chan string) bool
}

type Parameter

type Parameter struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Mandatory   bool   `yaml:"mandatory"`
	HasValue    bool   `yaml:"hasvalue"`
	SampleValue string `yaml:"sample"`
}

* Parameter structure, used for defining parameter data

type Settings

type Settings struct {
	DebugDisabled bool `yaml:"noDebug"`
}

func LoadSettings

func LoadSettings() (Settings, error)

Jump to

Keyboard shortcuts

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