Help us shape the future of Go! Take the 2026 Go Developer Survey

builder

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Delete = app.Register(&app.Command[app.Empty, app.Empty]{
	Use:    "builder {name}",
	Desc:   "Delete a builder",
	Action: "Delete",

	PrepareNoFlag: func(cmd *cobra.Command) {
		cmd.Args = cobra.ExactArgs(1)
		cmd.ValidArgsFunction = app.Comp(app.CompBuilder)
	},

	Run: func(ctx *app.Context[app.Empty, app.Empty]) error {
		name := ctx.Arg(0)
		path := config.GetDir("builders", name+".yaml")
		return app.Delete(ctx.Arg(0), path)
	},
})
View Source
var Edit = app.Register(&app.Command[app.Empty, app.Empty]{
	Use:    "builder {builder}",
	Desc:   "Edit builder file",
	Action: "Edit",

	PrepareNoFlag: func(cmd *cobra.Command) {
		cmd.Args = cobra.ExactArgs(1)
		cmd.ValidArgsFunction = app.Comp(app.CompBuilder)
	},

	Run: func(ctx *app.Context[app.Empty, app.Empty]) error {
		name := fmt.Sprintf("%s.yaml", ctx.Arg(0))
		path := config.GetDir("builders", name)
		return app.Edit(path, config.DefaultBuilder, name, func(s string) error {
			data := []byte(s)
			var builder core.Builder
			err := yaml.Unmarshal(data, &builder)
			if err != nil {
				return errors.Trace(err, "parse yaml")
			}
			return builder.Validate()
		})
	},
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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