file

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package file implements the core functionality to do with the spokfile.

Index

Constants

View Source
const NAME = "spokfile"

NAME is the canonical spok file name.

Variables

This section is empty.

Functions

func Find

func Find(logger logger.Logger, start, stop string) (string, error)

Find climbs the file tree from 'start' to 'stop' looking for a spokfile, if it hits 'stop' before finding one, an error will be returned If a spokfile is found, it's absolute path will be returned typical usage will make start = $CWD and stop = $HOME.

Types

type SpokFile

type SpokFile struct {
	Vars  map[string]string    // Global variables in IDENT: value form (functions already evaluated)
	Tasks map[string]task.Task // Map of task name to the task itself
	Globs map[string][]string  // Map of glob pattern to their concrete filepaths (avoids recalculating)
	Path  string               // The absolute path to the spokfile
	Dir   string               // The directory under which the spokfile sits
}

SpokFile represents a concrete spokfile.

func New

func New(tree ast.Tree, root string) (*SpokFile, error)

New converts a parsed spok AST into a concrete File object, root is the absolute path to the directory to use as root for glob expansion, typically the path to the directory the spokfile sits in.

func (*SpokFile) Env

func (s *SpokFile) Env() []string

Env returns the spokfile Vars as a string slice of KEY=VALUE format so it may be passed to running task commands.

func (*SpokFile) HasTask

func (s *SpokFile) HasTask(name string) bool

HasTask returns whether or not the SpokFile has a task with the given name.

func (*SpokFile) Run

func (s *SpokFile) Run(logger logger.Logger, stream iostream.IOStream, runner shell.Runner, force bool, tasks ...string) (task.Results, error)

Run runs the specified tasks, it takes force which is a boolean flag set by the CLI which always reruns tasks and an io.Writer which is used only to echo the commands being run, the command's stdout and stderr is stored in the result.

Jump to

Keyboard shortcuts

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