prompt

package
v0.0.0-...-b8af85d Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultTemplates

func GetDefaultTemplates() []string

GetDefaultTemplates returns the default templates defined by the prompt package

func GetTemplate

func GetTemplate(template string) (string, bool)

GetTemplate returns the a default template by its name

func GetTemplateOptions

func GetTemplateOptions(template string) (map[string]interface{}, bool)

GetTemplateOptions returns the default options for a default template

func ShowHelpPlugin

func ShowHelpPlugin(w io.Writer)

ShowHelpPlugin writes on w the plugin help

func ShowHelpTemplate

func ShowHelpTemplate(w io.Writer)

ShowHelpTemplate writes on w the templating help

Types

type Cache

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

Cache represents a cache data store

type Config

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

Config is the struct to fetch the config

func NewConfig

func NewConfig(r io.Reader) (*Config, error)

NewConfig returns a new Config struct from a io.ReadWriteCloser

func NewConfigFromFile

func NewConfigFromFile(file string) (*Config, error)

NewConfigFromFile loads the config from a file and returns the config

func (*Config) GetCustomTemplate

func (c *Config) GetCustomTemplate() (string, bool)

GetCustomTemplate returns the configured custom templatefile

func (*Config) GetOptions

func (c *Config) GetOptions() (map[string]interface{}, bool)

GetOptions return the configured options

func (*Config) GetTemplate

func (c *Config) GetTemplate() (string, bool)

GetTemplate returns the configured predefined template

type Plugin

type Plugin interface {
	Name() string
	Help() (description string, options map[string]string)
	Load(pr plugin.Prompter) error
	Get(format func(string, ...termcolor.Mode) string) (string, []termcolor.Mode)
}

Plugin is the interface all the plugins MUST implement

type Prompt

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

Prompt is the struct with the prompt options/config

func New

func New(options map[string]interface{}, color, debug bool) Prompt

New returns a new promp

func (Prompt) Cache

func (pr Prompt) Cache(key string, value interface{}) error

Cache caches a key, value on cache

func (*Prompt) Compile

func (pr *Prompt) Compile(tmpl string) string

Compile processes the template and returns a prompt string

func (Prompt) GetCache

func (pr Prompt) GetCache(key string) (interface{}, bool)

GetCache recovers a value from cache

func (Prompt) GetOption

func (pr Prompt) GetOption(key string) (interface{}, bool)

GetOption returns the option value for key

func (*Prompt) Load

func (pr *Prompt) Load(plugin string) (string, error)

func (*Prompt) Prefix

func (pr *Prompt) Prefix(prefix, input string) string

func (*Prompt) Replace

func (pr *Prompt) Replace(expr, repl, src string) (string, error)

func (*Prompt) Suffix

func (pr *Prompt) Suffix(suffix, input string) string

func (*Prompt) Wrap

func (pr *Prompt) Wrap(prefix, suffix string, input string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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