workspace

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BuildDir = "build-out"
View Source
const RootLabel = "//"

Variables

View Source
var ErrNoMakefileFound = errors.New("no Makefile found")
View Source
var ErrNoWorkspaceFound = errors.New("no WORKSPACE.mmake file found")
View Source
var ErrTargetExists = errors.New("target already exists")

Functions

func FileIsBuildFile

func FileIsBuildFile(path string) bool

func FindWorkspaceFile

func FindWorkspaceFile(ctx context.Context, inputPath string) (string, error)

FindWorkspaceFile finds the WORKSPACE.mmake relative to the current directory if a path is specified, it will search relative to that path. If the path is a WORKSPACE.mmake file, it will return that path.

func GetImportedCommand added in v0.5.0

func GetImportedCommand(args []string) string

func GetPackageFromFile

func GetPackageFromFile(filePath string, rootPath string) (string, error)

func HasCommandToImport added in v0.5.0

func HasCommandToImport(args []string) bool

HasCommandToImport returns true if the args contain a command to import a target e.g. mmake //services/api:api -- go run ./services/api will return true.

Types

type BuildFile

type BuildFile struct {
	// path to the build file
	Path string
	// label of the build file
	Label Label
	// list of targets in the build file
	Targets []string
	// the description of the build file (if any)
	Description string
}

func CreateBuildFile added in v0.5.0

func CreateBuildFile(path, label string, w io.Writer) (*BuildFile, error)

func ParseBuildFile

func ParseBuildFile(path string, rootDir string) (*BuildFile, error)

func (*BuildFile) CreateTarget added in v0.5.0

func (bf *BuildFile) CreateTarget(name string, targetBody io.Reader) error

CreateTarget creates a new target in the build file using the reader as the content of the target if the target already exists, then it will throw an error. opens a file handle to the build file.

func (*BuildFile) HasTarget added in v0.5.0

func (b *BuildFile) HasTarget(name string) bool

type ErrCommand

type ErrCommand struct {
	Err error
}

func (*ErrCommand) Error

func (e *ErrCommand) Error() string

func (*ErrCommand) Unwrap

func (e *ErrCommand) Unwrap() error

type ErrInvalidQuery

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

func (*ErrInvalidQuery) Error

func (e *ErrInvalidQuery) Error() string

type Label

type Label string

type Node

type Node struct {
	Children []*Node
	// contains filtered or unexported fields
}

func (*Node) Depth

func (n *Node) Depth(targetNode *Node) int

func (*Node) GetDeepestParent

func (n *Node) GetDeepestParent(child *Node) *Node

func (*Node) GetTreeAsList

func (n *Node) GetTreeAsList() []*Node

func (*Node) String

func (n *Node) String() string

type Query

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

func NewQuery

func NewQuery(ws *Workspace, updatePrefix string) *Query

func (*Query) GenComp

func (q *Query) GenComp(ctx context.Context, prefix string) (string, error)

GenComp completes the given prefix to a list of files and targets that match the prefix if there is a ':' in the input, it will complete to targets, otherwise it will complete to files. TODO: move this to the 'completion' package. TODO: use the tree structure to pick a subtree. Should be faster.

func (*Query) GetFileByLabel

func (q *Query) GetFileByLabel(label Label) *BuildFile

func (*Query) QueryFilesByPrefix

func (q *Query) QueryFilesByPrefix(ctx context.Context, prefix string) ([]*BuildFile, error)

QueryByPrefix returns a list of workspace-aware files that match the given prefix

func (*Query) QueryTargetsByFile

func (w *Query) QueryTargetsByFile(ctx context.Context, filePath string) ([]string, error)

QueryTargetsByFile returns a list of targets that are contained within the given file

func (*Query) Update

func (q *Query) Update(ctx context.Context, depth int) error

Update updates the workspace by re-scanning the workspace directory and re-parsing all of the Makefiles. Depth is the depth of the directory tree to scan relative to the first BuildFile found in a subtree. If depth is 0, then the entire tree is scanned.

type Workspace

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

func New

func New(rootPath string) *Workspace

func (*Workspace) Clean

func (w *Workspace) Clean(ctx context.Context, label string) error

func (*Workspace) GetInfo

func (w *Workspace) GetInfo(ctx context.Context, target string) (string, error)

func (*Workspace) Import added in v0.5.0

func (w *Workspace) Import(ctx context.Context, target string, args []string) error

func (*Workspace) Init

func (w *Workspace) Init(ctx context.Context) error

func (*Workspace) RunTarget

func (w *Workspace) RunTarget(ctx context.Context, target string) error

Jump to

Keyboard shortcuts

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