Documentation ¶
Index ¶
- Variables
- type BoolValue
- type BoolValuer
- type Category
- type DynamicBoolValue
- type DynamicStringValue
- type DynamicValue
- type ErrInvalidPattern
- type ErrOutOfRange
- type ErrTypeMismatch
- type GT
- type NewOptionOption
- type NewRepositoryOptions
- type Option
- func (s *Option) Default(currentValues *OptionValues) interface{}
- func (s *Option) Description() string
- func (s *Option) Name() string
- func (s *Option) PostHook(v interface{}, optionValues *OptionValues, targetDir string) error
- func (s *Option) ShouldDisplay(currentValues *OptionValues) bool
- func (s *Option) Validate(value interface{}) error
- type OptionNameToValue
- type OptionValues
- type Options
- type PostHookFunc
- type Streams
- type StringValue
- type StringValuer
- type Validator
- type ValidatorFunc
- type Value
- type Valuer
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyExists = errors.New("already exists") ErrParameterNotSet = errors.New("parameter not set") ErrMalformedInput = errors.New("malformed input") ErrParameterSet = errors.New("parameter set but has no effect in this context") ErrGoVersionNotSupported = fmt.Errorf("go version is not supported, gt requires at least %s", minGoVersion) )
Functions ¶
This section is empty.
Types ¶
type BoolValue ¶
type BoolValue bool
func (BoolValue) Value ¶
func (v BoolValue) Value(_ *OptionValues) bool
type BoolValuer ¶
type BoolValuer interface {
Value(vals *OptionValues) bool
}
type Category ¶
Category is used to wrap multiple extensions into one organizational unit. This is to reduce the amount of required user input if certain categories if extensions can be skipped as a category instead of needing to skip all one by one.
type DynamicBoolValue ¶
type DynamicBoolValue func(vals *OptionValues) bool
DefferedValue is a func that calculates the Value based on earlier inputs.
func (DynamicBoolValue) Value ¶
func (f DynamicBoolValue) Value(vals *OptionValues) bool
type DynamicStringValue ¶
type DynamicStringValue func(vals *OptionValues) string
DefferedValue is a func that calculates the Value based on earlier inputs.
func (DynamicStringValue) Value ¶
func (f DynamicStringValue) Value(vals *OptionValues) string
type DynamicValue ¶
type DynamicValue func(vals *OptionValues) interface{}
DefferedValue is a func that calculates the Value based on earlier inputs.
func (DynamicValue) Value ¶
func (f DynamicValue) Value(vals *OptionValues) interface{}
type ErrInvalidPattern ¶
ErrInvalidPattern indicates that an error occurred while matching a value with a pattern. The pattern as well as a description for the pattern is included in the error message.
func (*ErrInvalidPattern) Error ¶
func (e *ErrInvalidPattern) Error() string
type ErrOutOfRange ¶
func (*ErrOutOfRange) Error ¶
func (e *ErrOutOfRange) Error() string
type ErrTypeMismatch ¶
func (*ErrTypeMismatch) Error ¶
func (e *ErrTypeMismatch) Error() string
type GT ¶
type GT struct { Streams Options *Options FuncMap template.FuncMap GithubTagLister repos.GithubTagLister // contains filtered or unexported fields }
func (*GT) CheckVersion ¶
func (gt *GT) CheckVersion()
func (*GT) InitNewProject ¶
func (gt *GT) InitNewProject(opts *NewRepositoryOptions) (err error)
func (*GT) LoadConfigValuesFromFile ¶
func (gt *GT) LoadConfigValuesFromFile(file string) (*OptionValues, error)
LoadConfigValuesFromFile loads value for the options from a file and validates the inputs
func (*GT) LoadConfigValuesInteractively ¶
func (gt *GT) LoadConfigValuesInteractively() (*OptionValues, error)
func (*GT) PrintVersion ¶
func (gt *GT) PrintVersion()
type NewOptionOption ¶
type NewOptionOption func(*Option)
func WithPosthook ¶
func WithPosthook(postHook PostHookFunc) NewOptionOption
func WithShouldDisplay ¶
func WithShouldDisplay(shouldDisplay BoolValuer) NewOptionOption
func WithValidator ¶
func WithValidator(validator Validator) NewOptionOption
type NewRepositoryOptions ¶
type NewRepositoryOptions struct { OutputDir string OptionValues *OptionValues }
func (NewRepositoryOptions) Validate ¶
func (opts NewRepositoryOptions) Validate() error
Validate validates all properties of NewRepositoryOptions except the ConfigValues, since those are validated by the Load functions.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is a struct containing all needed configuration for options to customize the template.
func NewOption ¶
func NewOption(name, description string, defaultValue Valuer, opts ...NewOptionOption) Option
func (*Option) Default ¶
func (s *Option) Default(currentValues *OptionValues) interface{}
Default either returns the default value (possibly calculated with currentValues).
func (*Option) Description ¶
func (*Option) PostHook ¶
func (s *Option) PostHook(v interface{}, optionValues *OptionValues, targetDir string) error
PostHook executes the registered postHook if there is any.
func (*Option) ShouldDisplay ¶
func (s *Option) ShouldDisplay(currentValues *OptionValues) bool
ShouldDisplay returns a bool value indicating whether the option should be shown or not. If shouldDisplay variable is not set on the option true is returned.
type OptionNameToValue ¶
type OptionNameToValue map[string]interface{}
type OptionValues ¶
type OptionValues struct { Base OptionNameToValue `yaml:"base"` Extensions map[string]OptionNameToValue `yaml:"extensions"` }
OptionValues is a struct mirroring the structure of Options but using maps. Instead of the whole option only the set value of the option is kept. This makes looking up already supplied option values easier than it would be in the Options struct.
func NewOptionValues ¶
func NewOptionValues() *OptionValues
type Options ¶
Options is the main struct wrapping the configuration for all allowed parameters and extensions. Slices are used instead of maps since the iteration order of maps is undefined/random. which could lead to confusion.
func NewOptions ¶
func NewOptions(githubTagLister repos.GithubTagLister) *Options
NewOptions returns all of go/template's options.
type PostHookFunc ¶
type PostHookFunc func(value interface{}, optionValues *OptionValues, targetDir string) error
type StringValue ¶
type StringValue string
func (StringValue) Value ¶
func (v StringValue) Value(_ *OptionValues) string
type StringValuer ¶
type StringValuer interface {
Value(vals *OptionValues) string
}
type Validator ¶
type Validator interface {
Validate(value interface{}) error
}
Validator is a single method interface that validates that a given value is valid. If any error happens during validation or if the value is not valid an error will be returned.
type ValidatorFunc ¶
type ValidatorFunc func(value interface{}) error
ValidatorFunc is a function implementing the Validator interface.
func RangeValidator ¶
func RangeValidator(min, max int) ValidatorFunc
RangeValidator validates that value is in between or equal to min and max.
func RegexValidator ¶
func RegexValidator(pattern, description string) ValidatorFunc
RegexValidator returns a ValidatorFunc to validate a given value against a regex pattern. If the pattern doesn't match a ErrInvalidPattern is returned with a description on what the pattern means.
func (ValidatorFunc) Validate ¶
func (f ValidatorFunc) Validate(value interface{}) error
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func StaticValue ¶
func StaticValue(v interface{}) *Value
func (*Value) Value ¶
func (v *Value) Value(_ *OptionValues) interface{}
type Valuer ¶
type Valuer interface {
Value(vals *OptionValues) interface{}
}