termfx

package module
v0.0.0-...-0bd302f Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 6 Imported by: 0

README

TermFX

TermFX is a template file parser which supports variables and functions as callbacks. This package can be used allow users to specify custom output but have access to functions and variables without needing access to the code.

Examples: /examples

Credits

• Credits to Vayala for providing fasttemplate, this wouldn't have been a go module if it wasn't for them. (https://github.com/valyala/fasttemplate)

License

The MIT License (MIT)

Copyright (c) 2023 Jeffplays2005

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrFunctionAlreadyRegistered is returned after a command name conflict of a function
	ErrFunctionAlreadyRegistered = errors.New("function with the same name has already been registered")
)

Functions

This section is empty.

Types

type Registry

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

Registry contains all the registed commands and variables

func New

func New(split ...string) *Registry

New creates a new registry which can be used to register event call backs

func (*Registry) Execute

func (r *Registry) Execute(input string, writer io.Writer) error

Execute will parse and run a termfx file/input

func (*Registry) ExecuteString

func (r *Registry) ExecuteString(input string) (string, error)

ExecuteString will parse and run a termfx file/input and return the result as a string

func (*Registry) RegisterFunction

func (r *Registry) RegisterFunction(name string, function RegistryFunction) error

RegisterFunction will add the function to the registry

func (*Registry) RegisterVariable

func (r *Registry) RegisterVariable(name string, value string) error

RegisterVariable registers a variable

type RegistryFunction

type RegistryFunction func(session io.Writer, args string) (int, error)

RegistryFunction is used to register a function e.g. func(name: "exit", func) can be called as exit()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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