shexp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

shexp provides shell-like varianble expansions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(in io.Reader) (string, error)

func ExpandBytes

func ExpandBytes(b []byte) (string, error)

func ExpandString

func ExpandString(s string, args ...interface{}) (string, error)

Types

type EnvResolver

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

func (*EnvResolver) Get

func (r *EnvResolver) Get(key string) string

func (*EnvResolver) Reset

func (r *EnvResolver) Reset()

func (*EnvResolver) Set

func (r *EnvResolver) Set(key, value string) string

type Expander

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

A Expander is an object that can be used to Expand strings

func NewExpander

func NewExpander(r Resolver) *Expander

NewExpander allocates a new Expander using a given Resolver, or os.Getenv if none is given

func (*Expander) Expand

func (exp *Expander) Expand(in io.Reader) (string, error)

Expand expands variables on the text provided by a Reader

func (*Expander) ExpandBytes

func (exp *Expander) ExpandBytes(b []byte) (string, error)

ExpandBytes expands variables on a given text as []byte

func (*Expander) ExpandString

func (exp *Expander) ExpandString(s string, args ...interface{}) (string, error)

ExpandString expands variables on a given string

func (*Expander) Get

func (exp *Expander) Get(key string) string

Get resolves a variable names as the given Expander would do

func (*Expander) NewBytesParser

func (exp *Expander) NewBytesParser(b []byte) *Parser

func (*Expander) NewParser

func (exp *Expander) NewParser(in io.Reader) *Parser

func (*Expander) NewStringParser

func (exp *Expander) NewStringParser(s string, args ...interface{}) *Parser

Constructor

func (*Expander) Reset

func (exp *Expander) Reset()

Reset attempts to reset the Resolver if supported

func (*Expander) Set

func (exp *Expander) Set(key, value string) string

Set sets a variable to a given value for future use by the expander

type Parser

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

func (*Parser) Execute

func (p *Parser) Execute() (string, error)

type Resolver

type Resolver interface {
	Get(key string) string        // Gets value of a variable
	Set(key, value string) string // Sets a variable to a given value
}

A Resolver is an object used by the Expander to resolve and store variables

Jump to

Keyboard shortcuts

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