textcmd

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 4 Imported by: 1

README

Push

TextCmd

Go package implementing a simple text command shell and executor.

Usage

See USAGE.

License

Copyright (c) 2020 Eric Barkie. All rights reserved.
Use of this source code is governed by the MIT license that can be found in the LICENSE file.

Documentation

Overview

Package textcmd implements a simple text command shell and executor.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCmdNotFound = errors.New("command not found")
	ErrCmdQuit     = errors.New("quit command")
)

Errors.

Functions

This section is empty.

Types

type Env

type Env struct {
	net.Conn
	// contains filtered or unexported fields
}

Env is the command environment passed to a function.

func (Env) Arg

func (e Env) Arg(i int) (s string)

Arg returns the argument at index i. 0 is the command , 1 is the first argument, 2 is the second, etc. If an argument does not exist an empty string is returned.

type Shell

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

Shell is a text command shell for which commands can be registered and executed.

func (Shell) Exec

func (sh Shell) Exec(conn net.Conn, s string) error

Exec attempts to execute the passed string as a command.

func (*Shell) Register

func (sh *Shell) Register(f cmdFunc, cmd ...string)

Register adds a command to the text command shell. It takes a a command function and command execution strings.

Directories

Path Synopsis
internal
trie
Package trie implements a simple prefix tree.
Package trie implements a simple prefix tree.

Jump to

Keyboard shortcuts

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