summon

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: 23 Imported by: 0

Documentation

Overview

Package summon does the heavy lifting of instanciating files or executing configured scripts on the user's machine.

You can control instantiation by using Options described below.

Index

Constants

This section is empty.

Variables

View Source
var Name = "summon"

Name holds the name of the driver executable. By default it is "summon"

Functions

func FlattenStrings added in v0.12.0

func FlattenStrings(args ...interface{}) []string

FlattenStrings takes an array of string values or string slices and returns an flattened slice of strings.

func GetFs

func GetFs() afero.Fs

GetFs returns the current filesystem

Types

type ConfigurableLister added in v0.8.0

type ConfigurableLister interface {
	Configurer
	Lister
}

ConfigurableLister allows configuration and listing.

type ConfigurableRunner added in v0.8.0

type ConfigurableRunner interface {
	Configurer
	Runner
}

ConfigurableRunner is a runner that can be configured.

type Configurer added in v0.8.0

type Configurer interface {
	Configure(opts ...Option) error
}

Configurer allows configuring a driver from variadic options.

type Driver added in v0.8.0

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

Driver manages functionality of summon.

func New

func New(filesystem fs.FS, opts ...Option) (*Driver, error)

New creates the Driver.

func (*Driver) AddFlag added in v0.14.0

func (d *Driver) AddFlag(cmd *cobra.Command, name string, flagSpec *config.FlagSpec, global bool, callback func()) *flagValue

func (*Driver) AddFlags added in v0.14.0

func (d *Driver) AddFlags(cmd *cobra.Command, flags config.Flags, global bool)

func (*Driver) Configure added in v0.8.0

func (d *Driver) Configure(opts ...Option) error

Configure is used to extract options and customize the summon.Driver.

func (*Driver) ConstructCommandTree added in v0.14.0

func (d *Driver) ConstructCommandTree(root *cobra.Command, runCmdEnabled bool) (*cobra.Command, error)

func (Driver) HideAssetsInHelp added in v0.14.0

func (d Driver) HideAssetsInHelp() bool

func (*Driver) List added in v0.8.0

func (d *Driver) List(opts ...Option) ([]string, error)

List lists the content of the data tree.

func (Driver) OutputDir added in v0.14.0

func (d Driver) OutputDir() string

func (*Driver) RegisterFlags added in v0.15.0

func (d *Driver) RegisterFlags(runRoot *cobra.Command)

func (*Driver) RenderArgs added in v0.14.0

func (d *Driver) RenderArgs(args ...string) ([]string, error)

func (*Driver) Run added in v0.8.0

func (d *Driver) Run(opts ...Option) error

Run will run executable scripts described in the summon.config.yaml file of the data repository module.

func (*Driver) SetupRunArgs added in v0.15.0

func (d *Driver) SetupRunArgs(root *cobra.Command)

SetupRunArgs ensures that the cobra command receives correct arguments when help is requested.

func (*Driver) Summon added in v0.8.0

func (d *Driver) Summon(opts ...Option) (string, error)

Summon is the main command invocation

type Lister added in v0.8.0

type Lister interface {
	List(opts ...Option) ([]string, error)
}

Lister allows listing files in the assets.

type MainOptions added in v0.12.0

type MainOptions struct {
	WithoutRunSubcmd bool
}

MainOptions are used to configure summon at build time

type Option

type Option func(*options) error

Option allows specifying configuration settings from the user.

func All

func All(all bool) Option

All specifies to download all config files.

func Args

func Args(args ...string) Option

Args captures the arguments to be passed to run.

func CobraCmd added in v0.14.0

func CobraCmd(cmd *cobra.Command) Option

CobraCmd captures the cobra command that is executing

func Debug added in v0.10.0

func Debug(enable bool) Option

Debug prints debugging info on stderr

func Dest

func Dest(dest string) Option

Dest specifies where the file(s) will be rooted. '-' is a special value representing stdout.

func DryRun added in v0.10.0

func DryRun(enable bool) Option

DryRun does not run the command

func ExecCmd added in v0.8.0

func ExecCmd(e command.ExecCommandFn) Option

ExecCmd allows changing the execution function for external processes.

func Filename

func Filename(filename string) Option

Filename sets the requested filename in the embedded filesystem.

func JSON

func JSON(j *string) Option

JSON configures the dictionary to use to render a templated asset.

func Out added in v0.14.0

func Out(w io.Writer) Option

func Raw added in v0.4.0

func Raw(raw bool) Option

Raw disables any template rendering in assets.

func Ref

func Ref(ref string) Option

Ref references an exec config entry.

func ShowTree

func ShowTree(tree bool) Option

ShowTree will print a pretty graph of the data tree.

type Runner added in v0.8.0

type Runner interface {
	Run(opts ...Option) error
	ConstructCommandTree(*cobra.Command, bool) (*cobra.Command, error)
}

Runner allows executing configured aliases from summon.config.yaml.

type Summon added in v0.8.0

type Summon interface {
	Summon(opts ...Option) (string, error)
}

Summon is used to instantiate a real file to the filesystem.

type Summoner

type Summoner = Driver

Summoner is the old name for Driver, use Driver instead.

Jump to

Keyboard shortcuts

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