gorepl

package module
v0.0.0-...-7a52966 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 10 Imported by: 1

README

gorepl

GoRepl enables you to quickly create your own simple REPL in Go!

For a simple demp, please check this out! https://github.com/gilmardcom/gorepl-demo

Install

go get -u github.com/gilmardcom/gorepl

Example

Check: https://github.com/gilmardcom/gorepl-demo

Config

gorepl.Config.ConStatus = gorepl.CsDisonnected
// etc.

Adding your own commands to your REPL

	AddCommand("quit", "q", "quits the repl", func(args []string) (string, error) {
		StopRepl()
		return "", nil
	})

	AddCommand("clear", "c", "clears the screen", func(args []string) (string, error) {
		Clear()
		return "", nil
	})

Ready? Go REPL!

GoRepl()

License

The MIT License (MIT) - see LICENSE.md for more details.

Documentation

Overview

WIP

Index

Constants

This section is empty.

Variables

View Source
var Config = AppConfig{
	PathDelimiter:         "/",
	PromptSign:            "$",
	PromotSeparateLine:    false,
	PromptValue:           "gorepl",
	ShowPrompt:            true,
	EmptyLineBeforePrompt: true,
	ShowConnectionStatus:  true,
	ConStatus:             CsNoConnection,
	ConProtocol:           "TCP",
	ConHost:               "/localhost",
	ConPort:               8888,
	ColorError:            fcolor.New(fcolor.FgRed),
	ColorHelp:             fcolor.New(fcolor.FgHiWhite),
	ColorPrompt:           fcolor.New(fcolor.FgHiCyan, fcolor.BgBlue),
	ColorConnecting:       fcolor.New(fcolor.FgBlack, fcolor.BgYellow),
	ColorConnected:        fcolor.New(fcolor.FgBlack, fcolor.BgGreen),
	ColorDisconnected:     fcolor.New(fcolor.FgBlack, fcolor.BgRed),
	ColorPathDelimiter:    fcolor.New(fcolor.BgHiBlack),
	ColorPathOdd:          fcolor.New(fcolor.FgHiWhite, fcolor.BgHiBlack),
	ColorPathEven:         fcolor.New(fcolor.FgHiCyan, fcolor.BgHiBlack),
	ColorJsonString:       fcolor.New(fcolor.FgHiWhite),
	ColorJsonTrue:         fcolor.New(fcolor.FgGreen),
	ColorJsonFalse:        fcolor.New(fcolor.FgRed),
	ColorJsonNumber:       fcolor.New(fcolor.FgWhite),
	ColorJsonNull:         fcolor.New(fcolor.FgWhite, fcolor.Bold),
}

Functions

func AddCommand

func AddCommand(cmdName string, cmdAlias string, helpComment string, cmdHanlder CommandHandler)

func Clear

func Clear() error

func Connection

func Connection()

Connection status

func DefaultHelp

func DefaultHelp()

func Error

func Error(err string)

func Errorln

func Errorln(err string)

func GoRepl

func GoRepl()

func Json

func Json(data interface{})

func Path

func Path(data string)

Path

func Prompt

func Prompt()

func StopRepl

func StopRepl()

Types

type AppConfig

type AppConfig struct {
	PathDelimiter         string
	PromptSign            string
	PromotSeparateLine    bool
	PromptValue           string
	ShowPrompt            bool
	EmptyLineBeforePrompt bool
	ShowConnectionStatus  bool
	ConStatus             ConnectionStatus
	ConProtocol           string
	ConHost               string
	ConPort               int
	ColorError            *fcolor.Color
	ColorHelp             *fcolor.Color
	ColorPrompt           *fcolor.Color
	ColorConnecting       *fcolor.Color
	ColorConnected        *fcolor.Color
	ColorDisconnected     *fcolor.Color
	ColorPathDelimiter    *fcolor.Color
	ColorPathOdd          *fcolor.Color
	ColorPathEven         *fcolor.Color
	ColorJsonString       *fcolor.Color
	ColorJsonTrue         *fcolor.Color
	ColorJsonFalse        *fcolor.Color
	ColorJsonNumber       *fcolor.Color
	ColorJsonNull         *fcolor.Color
}

type CommandHandler

type CommandHandler func([]string) (string, error)

type ConnectionStatus

type ConnectionStatus int8
const (
	CsNoConnection ConnectionStatus = iota
	CsConnecting
	CsConnected
	CsDisonnected
)

Jump to

Keyboard shortcuts

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