Documentation ¶
Index ¶
- Constants
- Variables
- func HandleError(err int, msg string) errors.Error
- func PopValue_Helper(unset bool, param map[string]*Stack, vble string) (err_code int, err_str string)
- func Popparam_Helper(param map[string]*Stack, isrestp bool, isnamep bool) (int, string)
- func PrintError(s_err errors.Error)
- func PushOrSet(args []string, pushvalue bool) (int, string)
- func PushValue_Helper(set bool, param map[string]*Stack, vble, value string) (err_code int, err_str string)
- func Pushparam_Helper(param map[string]*Stack, isrestp bool, isnamep bool) (int, string)
- func Resolve(param string) (val value.Value, err_code int, err_str string)
- func StrToVal(param string) (val value.Value)
- func ValToStr(item value.Value) string
- type Alias
- type Connect
- type Copyright
- type Credential
- type Credentials
- type Disconnect
- type Echo
- type Exit
- type Help
- type Pop
- type Push
- type Set
- type ShellCommand
- type Source
- type Stack
- type Unalias
- type Unset
- type Version
Constants ¶
View Source
const ( ALIAS_CMD = "ALIAS" CONNECT_CMD = "CONNECT" DISCONNECT_CMD = "DISCONNECT" EXIT_CMD = "EXIT" QUIT_CMD = "QUIT" HELP_CMD = "HELP" VERSION_CMD = "VERSION" COPYRIGHT_CMD = "COPYRIGHT" SET_CMD = "SET" PUSH_CMD = "PUSH" POP_CMD = "POP" UNSET_CMD = "UNSET" ECHO_CMD = "ECHO" UNALIAS_CMD = "UNALIAS" SOURCE_CMD = "SOURCE" )
Variables ¶
View Source
var ( //Used to manage connections SERVICE_URL = "" //Used to disconnect from the endpoint DISCONNECT = false //Used to quit shell EXIT = false //Used to check for files FILE_INPUT = false //Total no. of commands MAX_COMMANDS = len(COMMAND_LIST) )
View Source
var ( QueryParam map[string]*Stack = map[string]*Stack{} NamedParam map[string]*Stack = map[string]*Stack{} UserDefSV map[string]*Stack = map[string]*Stack{} PreDefSV map[string]*Stack = map[string]*Stack{ "querycreds": Stack_Helper(), "limit": Stack_Helper(), "histfile": Stack_Helper(), "histsize": Stack_Helper(), "autoconfig": Stack_Helper(), "state": Stack_Helper(), } )
View Source
var AliasCommand = map[string]string{
"serverversion": "select version()",
}
Used to define aliases
View Source
var COMMAND_LIST = map[string]ShellCommand{ "\\connect": &Connect{}, "\\disconnect": &Disconnect{}, "\\exit": &Exit{}, "\\quit": &Exit{}, "\\help": &Help{}, "\\version": &Version{}, "\\copyright": &Copyright{}, "\\set": &Set{}, "\\push": &Push{}, "\\pop": &Pop{}, "\\unset": &Unset{}, "\\echo": &Echo{}, "\\alias": &Alias{}, "\\unalias": &Unalias{}, }
Command registry : List of Shell Commands supported by cbq
View Source
var W io.Writer
Define a common writer to output the responses to.
Functions ¶
func PopValue_Helper ¶
func PopValue_Helper(unset bool, param map[string]*Stack, vble string) (err_code int, err_str string)
Helper function to pop or unset a value in a stack.
func Popparam_Helper ¶
Pop the top value of the parameter stack.
This is used by the \POP command with no arguments.
func PushValue_Helper ¶
func PushValue_Helper(set bool, param map[string]*Stack, vble, value string) (err_code int, err_str string)
Helper function to push or set a value in a stack.
func Pushparam_Helper ¶
Push value from the Top of the stack onto the parameter stack.
This is used by the \PUSH command with no arguments.
func Resolve ¶
The Resolve method is used to evaluate the input parameter
to the \SET / \PUSH / \POP / \UNSET and \ECHO commands. It takes in a string, and resolves it to the appropriate value. The input string can be broadly classified into 2 categories, 1. Parameters (here we will need to read the top value from the parameter stack) 2. Actual values that can be converted to value.Value using the StrToVal method.
Types ¶
type Connect ¶
type Connect struct {
ShellCommand
}
Connect Command
func (*Connect) CommandCompletion ¶
type Copyright ¶
type Copyright struct {
ShellCommand
}
Copyright Command
func (*Copyright) CommandCompletion ¶
type Credential ¶
type Credentials ¶
type Credentials []Credential
type Disconnect ¶
type Disconnect struct {
ShellCommand
}
Disconnect Command
func (*Disconnect) CommandCompletion ¶
func (this *Disconnect) CommandCompletion() bool
func (*Disconnect) ExecCommand ¶
func (this *Disconnect) ExecCommand(args []string) (int, string)
func (*Disconnect) MaxArgs ¶
func (this *Disconnect) MaxArgs() int
func (*Disconnect) MinArgs ¶
func (this *Disconnect) MinArgs() int
func (*Disconnect) Name ¶
func (this *Disconnect) Name() string
type Exit ¶
type Exit struct {
ShellCommand
}
Exit and Quit Commands
func (*Exit) CommandCompletion ¶
type ShellCommand ¶
type ShellCommand interface { /* Name of the comand */ Name() string /* Return true if included in shell command completion */ CommandCompletion() bool /* Returns the Minimum number of input arguments required by the function */ MinArgs() int /* Returns the Maximum number of input arguments allowed by the function */ MaxArgs() int /* Method that implements the functionality */ ExecCommand(args []string) (int, string) /* Print Help information for command and its usage with an example */ PrintHelp(desc bool) (int, string) }
Interface to be implemented by shell commands.
type Stack ¶
Stack methods to be used for session parameters
type Unalias ¶
type Unalias struct {
ShellCommand
}
Unalias Command
func (*Unalias) CommandCompletion ¶
type Version ¶
type Version struct {
ShellCommand
}
Version Command
func (*Version) CommandCompletion ¶
Click to show internal directories.
Click to hide internal directories.