commands

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCommand

func RegisterCommand(commander Commander)

RegisterCommand appends commander object to collection registered commands for help and other

Types

type BaseCommand

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

BaseCommand base command fimpemeting commander interface

func NewBaseCommand

func NewBaseCommand(name string, minArgsCount, maxArgsCount int, desc, example string, callback func(string, ...string) error) *BaseCommand

NewBaseCommand constructor for private fields

func (BaseCommand) CallWithArgs

func (bc BaseCommand) CallWithArgs(args ...string) error

CallWithArgs invokes callback associated with command

func (BaseCommand) Name

func (bc BaseCommand) Name() string

Name returns Name associated with command

func (BaseCommand) ShowDescription

func (bc BaseCommand) ShowDescription() string

ShowDescription returns description associated with command

func (BaseCommand) ShowExample

func (bc BaseCommand) ShowExample() string

ShowExample returns example of use this command

func (BaseCommand) ValidateUserInput

func (bc BaseCommand) ValidateUserInput(args []string) error

ValidateUserInput validates args for this command, in base command only checks for count (args including name)

type Commander

type Commander interface {
	Name() string
	ShowDescription() string
	ShowExample() string
	ValidateUserInput([]string) error
	CallWithArgs(...string) error
}

Commander interface for command from userInput and for server parse

func GetCommand

func GetCommand(name string) Commander

GetCommand gets command by name or returns nil if not found

func NewAuthCommand

func NewAuthCommand(callback func(string, ...string) error) Commander

NewAuthCommand constructor standart server commands

func NewCreateTableCommand

func NewCreateTableCommand(callback func(string, ...string) error) Commander

NewCreateTableCommand constructor standart server commands

func NewExitCommand

func NewExitCommand(callback func(string, ...string) error) Commander

NewExitCommand constructor standart server commands

func NewGetCommand

func NewGetCommand(callback func(string, ...string) error) Commander

NewGetCommand constructor standart server commands

func NewHelpCommand

func NewHelpCommand() Commander

NewHelpCommand constructor standart server commands

func NewInsertIntoTableCommand

func NewInsertIntoTableCommand(callback func(string, ...string) error) Commander

NewInsertIntoTableCommand constructor standart server commands

func NewKeysCommand

func NewKeysCommand(callback func(string, ...string) error) Commander

NewSetCommand constructor standart server commands

func NewSelectCommand

func NewSelectCommand(callback func(string, ...string) error) Commander

NewSelectCommand constructor standart server commands

func NewSelectFromTableCommand

func NewSelectFromTableCommand(callback func(string, ...string) error) Commander

NewSelectFromTableCommand constructor standart server commands

func NewSetCommand

func NewSetCommand(callback func(string, ...string) error) Commander

NewSetCommand constructor standart server commands

func ParseCommand

func ParseCommand(input string, sep string) (Commander, []string, error)

ParseCommand parse userInput to Commander and validate args, and return them

Jump to

Keyboard shortcuts

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