config

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package config defines types and default values for summon.

Index

Constants

View Source
const (
	// DefaultOutputDir is where the files will be instantiated.
	DefaultOutputDir = ".summoned"

	// ConfigFileName is the name of the summon config file.
	ConfigFileName = "summon.config.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias map[string]string

Alias gives a shortcut to a name in data.

type ArgSliceSpec added in v0.14.0

type ArgSliceSpec []interface{}

ArgSliceSpec is the basic form of args to pass to invoker. It can be a slice of string, or slices of strings.

type CmdDesc added in v0.14.0

type CmdDesc struct {
	Cmd ArgSliceSpec `yaml:"cmd"`
	// Args contain the args that get appended to the ExecEnvironment
	Args ArgSliceSpec `yaml:"args"`
	// SubCmd describes a sub-command of current command
	SubCmd map[string]ExecDesc `yaml:"subCmd,omitempty"`
	// Flags of this command
	Flags map[string]FlagDesc `yaml:"flags,omitempty"`
	// Help line of this command
	Help string `yaml:"help,omitempty"`
	// Completion holds the command to invoke to have a completion of
	// this command. It can contain templates.
	Completion string `yaml:"completion,omitempty"`
	// Hidden hides the command from help
	Hidden bool `yaml:"hidden,omitempty"`
	// Join joins arguments to form one argument of one line of text
	Join *bool `yaml:"join,omitempty"`
}

CmdDesc describes a polymorphic Cmd in the config file. Its SubCmd is an ExecDesc so it can be an ArgsSliceSpec or a CmdSpec Its Flags can be a one line string flag or a FlagSpec

type Config

type Config struct {
	Version          int
	Aliases          Alias       `yaml:"aliases"`
	OutputDir        string      `yaml:"outputdir"`
	TemplateContext  string      `yaml:"templates"`
	Exec             ExecContext `yaml:"exec"`
	HideAssetsInHelp bool        `yaml:"hideAssetsInHelp"`
}

Config is the summon config

func (*Config) Unmarshal

func (c *Config) Unmarshal(config []byte) error

Unmarshal hidrates the config from config bytes.

type ExecContext added in v0.14.0

type ExecContext struct {
	ExecEnv     map[string]ExecDesc `yaml:"handles"`
	GlobalFlags map[string]FlagDesc `yaml:"flags"`
}

ExecContext houses execution handles and global flags

type ExecDesc added in v0.14.0

type ExecDesc struct {
	Value interface{}
}

ExecDesc allows unmarshalling complex subtype. Can be a slice of cmd args, or a CmdDesc

func (*ExecDesc) UnmarshalYAML added in v0.14.0

func (e *ExecDesc) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML the ExecDesc. It can be a CmdSpec or a ArgSliceSpec

type FlagDesc added in v0.14.0

type FlagDesc struct {
	Value interface{}
}

FlagDesc describes a simple string flag or complex FlagSpec

func (*FlagDesc) UnmarshalYAML added in v0.14.0

func (e *FlagDesc) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML the FlagSpec. It can be a String or a Flag

type FlagSpec added in v0.14.0

type FlagSpec struct {
	// Effect contains the value that will be assigned to the flag, after
	// template rendering, if needed
	Effect string `yaml:"effect"`
	// Shorthand (one letter) for the flag
	Shorthand string `yaml:"shorthand"`
	// Default value if the value is not provided by the user
	Default string `yaml:"default"`
	// Help for the flag
	Help string `yaml:"help"`
	// Explicit is used to control if the flag is added automatically or not to
	// the command-line. If Explicit is true, the flag will not be automatically
	// added (it can be positionned in the command-line with the flagValue template
	// function). The default is to add the rendered flag on the command line (implicit).
	// Note that using the {{ flagValue "my-flag" }} in a template makes the Flag Explicit.
	Explicit bool `yaml:"explicit"`
}

FlagSpec is used when you want more control on flag creation

type Flags added in v0.14.0

type Flags map[string]*FlagSpec

Flags are the normalized FlagDesc

Jump to

Keyboard shortcuts

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