dotgen

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dotgen provides functions to parse and manipulate dotgen configurations.

Index

Constants

This section is empty.

Variables

View Source
var Kinds = []string{"alias", "function", "raw", "run"}

Kinds represents the supported command kinds.

Functions

This section is empty.

Types

type Command

type Command struct {
	// Name is the name of the command.
	Name string `yaml:"name"`
	// Doc is the documentation string for the command.
	Doc string `yaml:"doc,omitempty"`
	// Cmd is the command to execute.
	Cmd string `yaml:"cmd"`
	// Kind is the type of command: "alias", "function", "raw", or "run".
	Kind string `yaml:"kind,omitempty"`
	// ExportTo is the path to export the command output.
	ExportTo string `yaml:"export_to,omitempty"`
	// Shell specifies the shells for which this command is applicable.
	Shell []string `yaml:"shell,omitempty"`
	// OS specifies the operating systems for which this command is applicable.
	OS []string `yaml:"os,omitempty"`
	// Exclude specifies whether to exclude this command from the output.
	Exclude bool `yaml:"exclude,omitempty"`
	// Timeout specifies the timeout for "run" commands.
	Timeout string `yaml:"timeout,omitempty"`
}

Command represents a single command definition, which can be an alias or a function.

func (*Command) Export

func (c *Command) Export(shell string) (string, error)

Export returns a string representation of the command, suitable for shell usage.

func (*Command) IsExcluded

func (c *Command) IsExcluded(os, shell string) bool

IsExcluded checks if the command should be excluded based on the provided OS and shell.

type Dotgen

type Dotgen struct {
	// Vars holds the variable definitions.
	Vars Vars `yaml:"vars,omitempty"`
	// Env holds the environment variable definitions.
	Env Env `yaml:"env,omitempty"`
	// Commands holds the command definitions.
	Commands []Command `yaml:"commands,omitempty"`
}

Dotgen represents the root structure of an dotgen configuration file.

func New

func New(data []byte) (dotgen Dotgen, err error)

New parses the provided YAML data into the Dotgen structure.

func (Dotgen) Export

func (a Dotgen) Export(shell, file string, instrument bool) (string, error)

Export returns a string representation of the Dotgen configuration.

func (Dotgen) Filtered

func (a Dotgen) Filtered(os, shell string) (dotgen Dotgen)

Filtered returns a new Dotgen instance with commands filtered based on the provided OS and shell.

func (Dotgen) Validate

func (a Dotgen) Validate() error

Validate checks the Dotgen configuration for any issues.

type Env

type Env map[string]string

Env represents environment variables to be set.

func (Env) Export

func (e Env) Export() string

Export returns a string representation of the environment variables, suitable for shell usage.

type Instrumentation added in v0.0.2

type Instrumentation struct {
	// Name is the name of the Dotgen file being instrumented.
	Name string

	// Enabled indicates whether instrumentation is enabled.
	Enabled bool
	// contains filtered or unexported fields
}

Instrumentation represents the instrumentation configuration for a Dotgen file.

func Instrument added in v0.0.2

func Instrument(file string) Instrumentation

Instrument creates an Instrumentation instance for the given Dotgen file.

func (*Instrumentation) Disable added in v0.0.2

func (i *Instrumentation) Disable()

Disable disables the instrumentation.

func (Instrumentation) Footer added in v0.0.2

func (i Instrumentation) Footer() string

Footer returns the footer section for instrumentation, including a summary of execution times.

func (Instrumentation) Header added in v0.0.2

func (i Instrumentation) Header() string

Header returns the header section for instrumentation.

func (Instrumentation) Wrap added in v0.0.2

func (i Instrumentation) Wrap(name, command string) string

Wrap wraps a command with instrumentation code to measure its execution time.

type Vars

type Vars map[string]string

Vars represents variables to be set.

func (Vars) Export

func (v Vars) Export() string

Export returns a string representation of the variables, suitable for shell usage.

Jump to

Keyboard shortcuts

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