plugin

package
v0.0.0-...-aea69b8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionSep   = ";"
	ArgSep      = "="
	ArgValueSep = ","
)
View Source
const (
	OptionTypeNone     = ""
	OptionTypeFlag     = "flag"
	OptionTypeArgKey   = "arg key"
	OptionTypeArgValue = "arg value"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Key    string
	Values []Value
}

func (Arg) GetSingleValue

func (arg Arg) GetSingleValue() *Value

func (Arg) MustGetSingleValue

func (arg Arg) MustGetSingleValue() Value

type ArgDescription

type ArgDescription struct {
	Key string
	//ValueDescription string
	DefaultValue     *Value
	ValidValues      *ValueSet
	AllowEmpty       bool
	IsMultipleValues bool
	Effect           string
}

type Description

type Description struct {
	Identity              string
	Effect                string
	ValidFlags            []FlagDescription
	ValidArgs             []ArgDescription
	AllowUnexpectedlyFlag bool
	AllowUnexpectedlyArg  bool
}

func (Description) ToHelpString

func (desc Description) ToHelpString() string

func (Description) Validate

func (desc Description) Validate(opts *Options) error

type Entries

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

func NewEntries

func NewEntries(capacity int) *Entries

func NewEntriesFromSlice

func NewEntriesFromSlice(slice []Entry) *Entries

func (*Entries) All

func (s *Entries) All(f func(Entry) bool) bool

func (*Entries) Any

func (s *Entries) Any(f func(Entry) bool) bool

func (*Entries) Append

func (s *Entries) Append(items ...Entry)

func (*Entries) Clear

func (s *Entries) Clear()

func (*Entries) Clone

func (s *Entries) Clone() *Entries

func (*Entries) Concat

func (s *Entries) Concat(another *Entries) *Entries

func (*Entries) CountBy

func (s *Entries) CountBy(f func(Entry) bool) uint

func (*Entries) DoUntil

func (s *Entries) DoUntil(f func(Entry) bool) int

func (*Entries) DoUntilError

func (s *Entries) DoUntilError(f func(Entry) error) error

func (*Entries) DoWhile

func (s *Entries) DoWhile(f func(Entry) bool) int

func (*Entries) Filter

func (s *Entries) Filter(f func(Entry) bool) *Entries

func (*Entries) FilterMap

func (s *Entries) FilterMap(f interface{}) interface{}

f: func(Entry) *T

func(Entry) (T, bool)
func(Entry) (T, error)

return: []T

func (*Entries) FindBy

func (s *Entries) FindBy(f func(Entry) bool) int

func (*Entries) FindLastBy

func (s *Entries) FindLastBy(f func(Entry) bool) int

func (*Entries) Fold

func (s *Entries) Fold(init Entry, f func(Entry, Entry) Entry) Entry

func (*Entries) ForEach

func (s *Entries) ForEach(f func(Entry))

func (*Entries) ForEachWithIndex

func (s *Entries) ForEachWithIndex(f func(int, Entry))

func (*Entries) GroupBy

func (s *Entries) GroupBy(f func(Entry) interface{}) map[interface{}]*Entries

func (*Entries) GroupByBool

func (s *Entries) GroupByBool(f func(Entry) bool) (trueGroup, falseGroup *Entries)

func (Entries) GroupByInt

func (s Entries) GroupByInt(f func(Entry) int) map[int]*Entries

func (Entries) GroupByStr

func (s Entries) GroupByStr(f func(Entry) string) map[string]*Entries

func (*Entries) InPlaceConcat

func (s *Entries) InPlaceConcat(another *Entries)

func (*Entries) Index

func (s *Entries) Index(idx int) *Entry

func (*Entries) IndexFrom

func (s *Entries) IndexFrom(idx int) *Entries

func (*Entries) IndexRange

func (s *Entries) IndexRange(from, to int) *Entries

func (*Entries) IndexTo

func (s *Entries) IndexTo(idx int) *Entries

func (*Entries) Insert

func (s *Entries) Insert(idx int, items ...Entry)

func (*Entries) IsEmpty

func (s *Entries) IsEmpty() bool

func (*Entries) Len

func (s *Entries) Len() int

func (*Entries) Map

func (s *Entries) Map(f interface{}) interface{}

f: func(Entry) T return: []T

func (Entries) MarshalJSON

func (s Entries) MarshalJSON() ([]byte, error)

func (*Entries) Reduce

func (s *Entries) Reduce(f func(Entry, Entry) Entry) Entry

func (*Entries) Remove

func (s *Entries) Remove(idx int)

func (*Entries) RemoveFrom

func (s *Entries) RemoveFrom(idx int)

func (*Entries) RemoveRange

func (s *Entries) RemoveRange(from, to int)

func (*Entries) RemoveTo

func (s *Entries) RemoveTo(idx int)

func (*Entries) String

func (s *Entries) String() string

func (*Entries) ToSlice

func (s *Entries) ToSlice() []Entry

func (*Entries) ToSliceRef

func (s *Entries) ToSliceRef() []Entry

func (*Entries) UnmarshalJSON

func (s *Entries) UnmarshalJSON(b []byte) error

type Entry

type Entry struct {
	Plugin string
	Opts   *Options
}

derive-slice: Rename=Entries

func MakeEntry

func MakeEntry(p string, opts *Options) Entry

func (*Entry) IsEmpty

func (e *Entry) IsEmpty() bool

type Env

type Env struct {
	PkgName string
	Imports *ImportSet
}

func MakeEnv

func MakeEnv(pkgName string) Env

func (Env) SelectImportForType

func (e Env) SelectImportForType(typ string) *Import

type Flag

type Flag string

type FlagDescription

type FlagDescription struct {
	Key     string
	Default utils.TriBool
	Effect  string
}

type Import

type Import struct {
	Name string
	Path string
}

derive-set: Order=Key

func MakeImport

func MakeImport(path string) Import

func MakeImportFromAst

func MakeImportFromAst(i *ast.ImportSpec) Import

func MakeRenamedImport

func MakeRenamedImport(name, path string) Import

func (Import) PkgName

func (i Import) PkgName() (string, bool)

func (Import) String

func (i Import) String() string

type ImportSet

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

func NewImportSet

func NewImportSet(capacity int, cmp func(i, j Import) bool) *ImportSet

func NewImportSetFromSlice

func NewImportSetFromSlice(items []Import, cmp func(i, j Import) bool) *ImportSet

func (*ImportSet) All

func (set *ImportSet) All(f func(Import) bool) bool

func (*ImportSet) Any

func (set *ImportSet) Any(f func(Import) bool) bool

func (*ImportSet) Append

func (set *ImportSet) Append(keys ...Import)

func (*ImportSet) Clear

func (set *ImportSet) Clear()

func (*ImportSet) Clone

func (set *ImportSet) Clone() *ImportSet

func (*ImportSet) Contains

func (set *ImportSet) Contains(key Import) bool

func (*ImportSet) ContainsAll

func (set *ImportSet) ContainsAll(keys ...Import) bool

func (*ImportSet) ContainsAny

func (set *ImportSet) ContainsAny(keys ...Import) bool

func (*ImportSet) CountBy

func (set *ImportSet) CountBy(f func(Import) bool) int

func (*ImportSet) Difference

func (set *ImportSet) Difference(another *ImportSet) *ImportSet

func (*ImportSet) DoUntil

func (set *ImportSet) DoUntil(f func(Import) bool) int

func (*ImportSet) DoUntilError

func (set *ImportSet) DoUntilError(f func(Import) error) error

func (*ImportSet) DoWhile

func (set *ImportSet) DoWhile(f func(Import) bool) int

func (*ImportSet) Equal

func (set *ImportSet) Equal(another *ImportSet) bool

func (*ImportSet) Filter

func (set *ImportSet) Filter(f func(Import) bool) *ImportSet

func (*ImportSet) FilterMap

func (set *ImportSet) FilterMap(f interface{}) interface{}

f: func(Import) *T

func(Import) (T, bool)
func(Import) (T, error)

return: []T

func (*ImportSet) FindBy

func (set *ImportSet) FindBy(f func(Import) bool) *Import

func (*ImportSet) FindLastBy

func (set *ImportSet) FindLastBy(f func(Import) bool) *Import

func (*ImportSet) Fold

func (set *ImportSet) Fold(init Import, f func(Import, Import) Import) Import

func (*ImportSet) ForEach

func (set *ImportSet) ForEach(f func(Import))

func (*ImportSet) ForEachWithIndex

func (set *ImportSet) ForEachWithIndex(f func(int, Import))

func (*ImportSet) GroupBy

func (set *ImportSet) GroupBy(f func(Import) interface{}) map[interface{}]*ImportSet

func (*ImportSet) GroupByBool

func (set *ImportSet) GroupByBool(f func(Import) bool) (trueGroup *ImportSet, falseGroup *ImportSet)

func (*ImportSet) GroupByInt

func (set *ImportSet) GroupByInt(f func(Import) int) map[int]*ImportSet

func (*ImportSet) GroupByStr

func (set *ImportSet) GroupByStr(f func(Import) string) map[string]*ImportSet

func (*ImportSet) InPlaceUnion

func (set *ImportSet) InPlaceUnion(another *ImportSet)

func (*ImportSet) Intersect

func (set *ImportSet) Intersect(another *ImportSet) *ImportSet

func (*ImportSet) IsEmpty

func (set *ImportSet) IsEmpty() bool

func (*ImportSet) IsProperSubsetOf

func (set *ImportSet) IsProperSubsetOf(another *ImportSet) bool

func (*ImportSet) IsProperSupersetOf

func (set *ImportSet) IsProperSupersetOf(another *ImportSet) bool

func (*ImportSet) IsSubsetOf

func (set *ImportSet) IsSubsetOf(another *ImportSet) bool

func (*ImportSet) IsSupersetOf

func (set *ImportSet) IsSupersetOf(another *ImportSet) bool

func (*ImportSet) Len

func (set *ImportSet) Len() int

func (*ImportSet) Map

func (set *ImportSet) Map(f interface{}) interface{}

f: func(Import) T return: []T

func (ImportSet) MarshalJSON

func (set ImportSet) MarshalJSON() ([]byte, error)

func (*ImportSet) Reduce

func (set *ImportSet) Reduce(f func(Import, Import) Import) Import

func (*ImportSet) Remove

func (set *ImportSet) Remove(key Import)

func (*ImportSet) String

func (set *ImportSet) String() string

func (*ImportSet) ToSlice

func (set *ImportSet) ToSlice() []Import

func (*ImportSet) ToSliceRef

func (set *ImportSet) ToSliceRef() []Import

NOTICE: efficient but unsafe

func (*ImportSet) Union

func (set *ImportSet) Union(another *ImportSet) *ImportSet

func (*ImportSet) UnmarshalJSON

func (set *ImportSet) UnmarshalJSON(b []byte) error

type OptionType

type OptionType string

func (OptionType) IsIdent

func (ot OptionType) IsIdent() bool

func (OptionType) IsUnique

func (ot OptionType) IsUnique() bool

type Options

type Options struct {
	// TODO keep order
	Flags          map[Flag]utils.TriBool
	Args           map[string]Arg
	ExistingOption map[string]OptionType
}

TODO support base plugin, e.g. plugin to define collection interface for other plugins TODO pop operation TODO arg with default value as flag

func NewOptions

func NewOptions() *Options

func ParseOptions

func ParseOptions(optsStr string) (*Options, error)

func (Options) GetFlag

func (opts Options) GetFlag(flag Flag) utils.TriBool

func (Options) GetValue

func (opts Options) GetValue(key string) *Value

func (Options) GetValues

func (opts Options) GetValues(key string) ([]Value, error)

func (Options) GetValuesOrEmpty

func (opts Options) GetValuesOrEmpty(key string) []Value

func (*Options) IsEmpty

func (opts *Options) IsEmpty() bool

func (*Options) Merge

func (opts *Options) Merge(another *Options) error

func (Options) MustGetValue

func (opts Options) MustGetValue(key string) Value

func (*Options) SetArg

func (opts *Options) SetArg(arg Arg)

func (*Options) SetFlag

func (opts *Options) SetFlag(flag string, val utils.TriBool)

func (Options) ValidateOption

func (opts Options) ValidateOption(optType OptionType, opt string) error

func (Options) WithFlag

func (opts Options) WithFlag(flag Flag) bool

func (Options) WithNegativeFlag

func (opts Options) WithNegativeFlag(flag Flag) bool

type Plugin

type Plugin interface {
	Describe() Description
	GenerateTo(w io.Writer, env Env, typeInfo TypeInfo, opt Options) (Prerequisites, error)
}

derive-set: Order=Append

type PluginSet

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

func NewPluginSet

func NewPluginSet(capacity int) *PluginSet

func NewPluginSetFromSlice

func NewPluginSetFromSlice(items []Plugin) *PluginSet

func (*PluginSet) All

func (set *PluginSet) All(f func(Plugin) bool) bool

func (*PluginSet) Any

func (set *PluginSet) Any(f func(Plugin) bool) bool

func (*PluginSet) Append

func (set *PluginSet) Append(keys ...Plugin)

func (*PluginSet) Clear

func (set *PluginSet) Clear()

func (*PluginSet) Clone

func (set *PluginSet) Clone() *PluginSet

func (*PluginSet) Contains

func (set *PluginSet) Contains(key Plugin) bool

func (*PluginSet) ContainsAll

func (set *PluginSet) ContainsAll(keys ...Plugin) bool

func (*PluginSet) ContainsAny

func (set *PluginSet) ContainsAny(keys ...Plugin) bool

func (*PluginSet) CountBy

func (set *PluginSet) CountBy(f func(Plugin) bool) int

func (*PluginSet) Difference

func (set *PluginSet) Difference(another *PluginSet) *PluginSet

func (*PluginSet) DoUntil

func (set *PluginSet) DoUntil(f func(Plugin) bool) int

func (*PluginSet) DoUntilError

func (set *PluginSet) DoUntilError(f func(Plugin) error) error

func (*PluginSet) DoWhile

func (set *PluginSet) DoWhile(f func(Plugin) bool) int

func (*PluginSet) Equal

func (set *PluginSet) Equal(another *PluginSet) bool

func (*PluginSet) Filter

func (set *PluginSet) Filter(f func(Plugin) bool) *PluginSet

func (*PluginSet) FilterMap

func (set *PluginSet) FilterMap(f interface{}) interface{}

f: func(Plugin) *T

func(Plugin) (T, bool)
func(Plugin) (T, error)

return: []T

func (*PluginSet) FindBy

func (set *PluginSet) FindBy(f func(Plugin) bool) *Plugin

func (*PluginSet) FindLastBy

func (set *PluginSet) FindLastBy(f func(Plugin) bool) *Plugin

func (*PluginSet) Fold

func (set *PluginSet) Fold(init Plugin, f func(Plugin, Plugin) Plugin) Plugin

func (*PluginSet) ForEach

func (set *PluginSet) ForEach(f func(Plugin))

func (*PluginSet) ForEachWithIndex

func (set *PluginSet) ForEachWithIndex(f func(int, Plugin))

func (*PluginSet) GroupBy

func (set *PluginSet) GroupBy(f func(Plugin) interface{}) map[interface{}]*PluginSet

func (*PluginSet) GroupByBool

func (set *PluginSet) GroupByBool(f func(Plugin) bool) (trueGroup *PluginSet, falseGroup *PluginSet)

func (*PluginSet) GroupByInt

func (set *PluginSet) GroupByInt(f func(Plugin) int) map[int]*PluginSet

func (*PluginSet) GroupByStr

func (set *PluginSet) GroupByStr(f func(Plugin) string) map[string]*PluginSet

func (*PluginSet) InPlaceUnion

func (set *PluginSet) InPlaceUnion(another *PluginSet)

func (*PluginSet) Intersect

func (set *PluginSet) Intersect(another *PluginSet) *PluginSet

TODO keep order

func (*PluginSet) IsEmpty

func (set *PluginSet) IsEmpty() bool

func (*PluginSet) IsProperSubsetOf

func (set *PluginSet) IsProperSubsetOf(another *PluginSet) bool

func (*PluginSet) IsProperSupersetOf

func (set *PluginSet) IsProperSupersetOf(another *PluginSet) bool

func (*PluginSet) IsSubsetOf

func (set *PluginSet) IsSubsetOf(another *PluginSet) bool

func (*PluginSet) IsSupersetOf

func (set *PluginSet) IsSupersetOf(another *PluginSet) bool

func (*PluginSet) Len

func (set *PluginSet) Len() int

func (*PluginSet) Map

func (set *PluginSet) Map(f interface{}) interface{}

f: func(Plugin) T return: []T

func (PluginSet) MarshalJSON

func (set PluginSet) MarshalJSON() ([]byte, error)

func (*PluginSet) Reduce

func (set *PluginSet) Reduce(f func(Plugin, Plugin) Plugin) Plugin

func (*PluginSet) Remove

func (set *PluginSet) Remove(key Plugin)

func (*PluginSet) String

func (set *PluginSet) String() string

func (*PluginSet) ToSlice

func (set *PluginSet) ToSlice() []Plugin

func (*PluginSet) ToSliceRef

func (set *PluginSet) ToSliceRef() []Plugin

NOTICE: efficient but unsafe

func (*PluginSet) Union

func (set *PluginSet) Union(another *PluginSet) *PluginSet

func (*PluginSet) UnmarshalJSON

func (set *PluginSet) UnmarshalJSON(b []byte) error

type Prerequisites

type Prerequisites struct {
	Imports *ImportSet
}

func MakePrerequisites

func MakePrerequisites() Prerequisites

type TypeInfo

type TypeInfo struct {
	Name     string
	Assigned string
	Ast      ast.Expr
}

type Value

type Value string

derive-set:Order=Append

func (*Value) IsNil

func (v *Value) IsNil() bool

func (*Value) Str

func (v *Value) Str() string

type ValueSet

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

func NewValueSet

func NewValueSet(capacity int) *ValueSet

func NewValueSetFromSlice

func NewValueSetFromSlice(items []Value) *ValueSet

func (*ValueSet) All

func (set *ValueSet) All(f func(Value) bool) bool

func (*ValueSet) Any

func (set *ValueSet) Any(f func(Value) bool) bool

func (*ValueSet) Append

func (set *ValueSet) Append(keys ...Value)

func (*ValueSet) Clear

func (set *ValueSet) Clear()

func (*ValueSet) Clone

func (set *ValueSet) Clone() *ValueSet

func (*ValueSet) Contains

func (set *ValueSet) Contains(key Value) bool

func (*ValueSet) ContainsAll

func (set *ValueSet) ContainsAll(keys ...Value) bool

func (*ValueSet) ContainsAny

func (set *ValueSet) ContainsAny(keys ...Value) bool

func (*ValueSet) CountBy

func (set *ValueSet) CountBy(f func(Value) bool) int

func (*ValueSet) Difference

func (set *ValueSet) Difference(another *ValueSet) *ValueSet

func (*ValueSet) DoUntil

func (set *ValueSet) DoUntil(f func(Value) bool) int

func (*ValueSet) DoUntilError

func (set *ValueSet) DoUntilError(f func(Value) error) error

func (*ValueSet) DoWhile

func (set *ValueSet) DoWhile(f func(Value) bool) int

func (*ValueSet) Equal

func (set *ValueSet) Equal(another *ValueSet) bool

func (*ValueSet) Filter

func (set *ValueSet) Filter(f func(Value) bool) *ValueSet

func (*ValueSet) FilterMap

func (set *ValueSet) FilterMap(f interface{}) interface{}

f: func(Value) *T

func(Value) (T, bool)
func(Value) (T, error)

return: []T

func (*ValueSet) FindBy

func (set *ValueSet) FindBy(f func(Value) bool) *Value

func (*ValueSet) FindLastBy

func (set *ValueSet) FindLastBy(f func(Value) bool) *Value

func (*ValueSet) Fold

func (set *ValueSet) Fold(init Value, f func(Value, Value) Value) Value

func (*ValueSet) ForEach

func (set *ValueSet) ForEach(f func(Value))

func (*ValueSet) ForEachWithIndex

func (set *ValueSet) ForEachWithIndex(f func(int, Value))

func (*ValueSet) GroupBy

func (set *ValueSet) GroupBy(f func(Value) interface{}) map[interface{}]*ValueSet

func (*ValueSet) GroupByBool

func (set *ValueSet) GroupByBool(f func(Value) bool) (trueGroup *ValueSet, falseGroup *ValueSet)

func (*ValueSet) GroupByInt

func (set *ValueSet) GroupByInt(f func(Value) int) map[int]*ValueSet

func (*ValueSet) GroupByStr

func (set *ValueSet) GroupByStr(f func(Value) string) map[string]*ValueSet

func (*ValueSet) InPlaceUnion

func (set *ValueSet) InPlaceUnion(another *ValueSet)

func (*ValueSet) Intersect

func (set *ValueSet) Intersect(another *ValueSet) *ValueSet

TODO keep order

func (*ValueSet) IsEmpty

func (set *ValueSet) IsEmpty() bool

func (*ValueSet) IsProperSubsetOf

func (set *ValueSet) IsProperSubsetOf(another *ValueSet) bool

func (*ValueSet) IsProperSupersetOf

func (set *ValueSet) IsProperSupersetOf(another *ValueSet) bool

func (*ValueSet) IsSubsetOf

func (set *ValueSet) IsSubsetOf(another *ValueSet) bool

func (*ValueSet) IsSupersetOf

func (set *ValueSet) IsSupersetOf(another *ValueSet) bool

func (*ValueSet) Len

func (set *ValueSet) Len() int

func (*ValueSet) Map

func (set *ValueSet) Map(f interface{}) interface{}

f: func(Value) T return: []T

func (ValueSet) MarshalJSON

func (set ValueSet) MarshalJSON() ([]byte, error)

func (*ValueSet) Reduce

func (set *ValueSet) Reduce(f func(Value, Value) Value) Value

func (*ValueSet) Remove

func (set *ValueSet) Remove(key Value)

func (*ValueSet) String

func (set *ValueSet) String() string

func (*ValueSet) ToSlice

func (set *ValueSet) ToSlice() []Value

func (*ValueSet) ToSliceRef

func (set *ValueSet) ToSliceRef() []Value

NOTICE: efficient but unsafe

func (*ValueSet) Union

func (set *ValueSet) Union(another *ValueSet) *ValueSet

func (*ValueSet) UnmarshalJSON

func (set *ValueSet) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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