internal

package
v0.0.0-...-bb8472d Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

This file adds a simple wrapper around some os's methods so that they can be stubbed easily in a testing scenario. LocalFileSystem is the concrete implementation MemFileSystem is the one used in tests

Index

Constants

View Source
const CURRENT_VERSION = "0.2.6"
View Source
const DefaultTask = "main"

This represent the default task, so when the user doesn't provide any args to the program, we default to this.

Variables

This section is empty.

Functions

func CreateGokeConfig

func CreateGokeConfig() error

func CurrentConfigFile

func CurrentConfigFile() string

func FileExists

func FileExists(filename string) bool

func GOBDeserialize

func GOBDeserialize[T any](structStr string, structShell *T) T

Deserialize a struct

func GOBSerialize

func GOBSerialize[T any](structInstance T) string

Serialize a struct

func GokeFiles

func GokeFiles() []string

func JoinInnerArgs

func JoinInnerArgs(args []string) string

func ReadYamlConfig

func ReadYamlConfig() (string, error)

Types

type Executor

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

func NewExecutor

func NewExecutor(p *Parseable, l *Lockfile, opts *Options, proc Process, fs FileSystem, ctx *context.Context) Executor

Executor constructor.

func (*Executor) Start

func (e *Executor) Start(taskName string)

Starts the command for a single run or as a watcher.

type FileSystem

type FileSystem interface {
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm fs.FileMode) error
	Getwd() (dir string, err error)
	Stat(name string) (fs.FileInfo, error)
	FileExists(filename string) bool
	Remove(name string) error
	TempDir() string
	Glob(path string) ([]string, error)
}

type Global

type Global struct {
	Shared struct {
		Env    map[string]string `yaml:"environment,omitempty"`
		Events struct {
			BeforeEachRun  []string `yaml:"before_each_run,omitempty"`
			AfterEachRun   []string `yaml:"after_each_run,omitempty"`
			BeforeEachTask []string `yaml:"before_each_task,omitempty"`
			AfterEachTask  []string `yaml:"after_each_task,omitempty"`
		} `yaml:"events,omitempty"`
	} `yaml:"global,omitempty"`
}

type LocalFileSystem

type LocalFileSystem struct{}

func (*LocalFileSystem) FileExists

func (fs *LocalFileSystem) FileExists(filename string) bool

func (*LocalFileSystem) Getwd

func (fs *LocalFileSystem) Getwd() (dir string, err error)

func (*LocalFileSystem) Glob

func (fs *LocalFileSystem) Glob(path string) ([]string, error)

func (*LocalFileSystem) ReadFile

func (fs *LocalFileSystem) ReadFile(name string) ([]byte, error)

func (*LocalFileSystem) Remove

func (fs *LocalFileSystem) Remove(name string) error

func (*LocalFileSystem) Stat

func (fs *LocalFileSystem) Stat(name string) (fs.FileInfo, error)

func (*LocalFileSystem) TempDir

func (fs *LocalFileSystem) TempDir() string

func (*LocalFileSystem) WriteFile

func (fs *LocalFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error

type Lockfile

type Lockfile struct {
	JSON lockFileJson
	// contains filtered or unexported fields
}

func NewLockfile

func NewLockfile(files []string, opts *Options, fs FileSystem) Lockfile

func (*Lockfile) Bootstrap

func (l *Lockfile) Bootstrap()

Loads existing lock information generates it for the first time.

func (*Lockfile) GetCurrentProject

func (l *Lockfile) GetCurrentProject() singleProjectJson

Returns the lock information for the current project.

func (*Lockfile) UpdateTimestampsForFiles

func (l *Lockfile) UpdateTimestampsForFiles(files []string) error

Update timestamps for files in current project.

type OptionHandler

type OptionHandler struct {
	NeedsParser bool
	Func        func(*Parseable) (int, error)
}

type Options

type Options struct {
	TaskName string   `docopt:"<task>"`
	Watch    bool     `docopt:"-w,--watch"`
	NoCache  bool     `docopt:"-c,--no-cache"`
	Force    bool     `docopt:"-f,--force"`
	Quiet    bool     `docopt:"-q,--quiet"`
	Args     []string `docopt:"-a,--args"`
	Init     bool     `docopt:"-i,--init"`
	Tasks    bool     `docopt:"-t,--tasks"`
}

func NewCliOptions

func NewCliOptions() Options

func (Options) Handlers

func (opts Options) Handlers(p *Parseable) []OptionHandler

Handlers groups the handlers into a slice so that we can run them all at once when used.

type Parseable

type Parseable interface {
	Bootstrap()
	GetGlobal() *Global
	GetTask(string) (Task, bool)
	GetFilePaths() []string
	// contains filtered or unexported methods
}

func NewParser

func NewParser(cfg string, opts *Options, fs FileSystem) Parseable

NewParser creates a parser instance which can be either a blank one, or one provided from the cache, which gets deserialized.

type Process

type Process interface {
	Execute(name string, args ...string) ([]byte, error)
	Fprint(w io.Writer, a ...any) (n int, err error)
	Exit(code int)
}

type Ref

type Ref[T any] struct {
	// contains filtered or unexported fields
}

func NewRef

func NewRef[T any](value T, err error) Ref[T]

func (*Ref[T]) Error

func (r *Ref[T]) Error() error

func (*Ref[T]) Value

func (r *Ref[T]) Value() T

type ShellProcess

type ShellProcess struct{}

func (*ShellProcess) Execute

func (sp *ShellProcess) Execute(name string, args ...string) ([]byte, error)

func (*ShellProcess) Exit

func (sp *ShellProcess) Exit(code int)

func (*ShellProcess) Fprint

func (sp *ShellProcess) Fprint(w io.Writer, a ...any) (n int, err error)

type Task

type Task struct {
	Name  string
	Files []string          `yaml:"files,omitempty"`
	Run   []string          `yaml:"run"`
	Env   map[string]string `yaml:"env,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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