gobl

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: GPL-3.0 Imports: 9 Imported by: 10

README

gobl - Go Build

Go Reference

gobl is an experimental build system that uses Go to define and run build tasks. Although it is actively used to develop other programs, it is by no means stable and may have breaking API changes if any redesigns are required. However, syntax should largely remain the same, as I find its current syntax to be simple to use, which is one of the primary goals of it.

Quickstart

In your project root directory, simply create a file called gobl.go and fill its contents with the following:

package main

import (
	. "github.com/kettek/gobl"
)

func main() {
	Task("listFiles").
		Exec("ls")

	Go()
}

You will likely have to get the gobl dependency by issuing go get -d github.com/kettek/gobl.

At this point, you can list the tasks by issuing go run . and then run the specific task with go run . listFiles

A more complex example that would allow automatic rebuilding + running, would be:

package main

import (
	. "github.com/kettek/gobl"
)

func main() {
	Task("build").
		Exec("go", "build", "./cmd/mycmd")

	Task("run").
		Exec("mycmd")

	Task("watch").
		Watch("./pkg/*/*.go").
		Signaler(SigQuit).
		Run("build").
		Run("run")

	Go()
}

Task Steps

For a complete rundown of available steps, see the godoc task reference.

Visual Studio Code Integration

There is a task provider extension for VSCode that allows using gobl tasks as VSCode tasks. It is available as Gobl Task Provider and has a GitHub repository here.

Why

* 1. I like Go.
* 2. Having the full power of Go available for setting up and running build tasks is very convenient.
* 3. Go's syntax is elegant.
* 4. It's an interesting concept.

Of course, there are some inconveniences, such as:

* 1. Technically running `go run .` does first compile the task script and run it from a temporary directory.
* 2. It takes the place of `main() {...}` in whatever directory it is in. This shouldn't be problem for most popular go project layout styles, but could be an issue for some.
* 3. `go.mod` and `go.sum` adds some clutter.

Documentation

Index

Constants

View Source
const (
	SigQuit      = syscall.SIGQUIT
	SigInterrupt = syscall.SIGINT
)

Our various Signals

Variables

This section is empty.

Functions

func Go

func Go()

Go runs a specified task or lists all tasks if no task is specified.

func PrintTasks

func PrintTasks()

PrintTasks prints the currently available tasks.

func RunTask

func RunTask(taskName string) (errChan chan steps.Result)

RunTask begins running a specifc named task.

func Task

func Task(name string) *task.Task

Task is a container for various steps.

Types

type Context

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

Context provides a task-specific set of properties.

func (*Context) AddEnv

func (c *Context) AddEnv(args ...string)

AddEnv adds an environment variable.

func (*Context) AddProcessKillChannel

func (c *Context) AddProcessKillChannel(r chan steps.Result)

AddProcessKillChannel adds a provided channel to be sent a killed signal.

func (*Context) GetEnv

func (c *Context) GetEnv() []string

GetEnv returns the current environment variables, including OS.

func (*Context) GetProcessKillChannels

func (c *Context) GetProcessKillChannels() []chan steps.Result

GetProcessKillChannels returns the underlying process kill channels slice.

func (*Context) RemoveProcessKillChannel

func (c *Context) RemoveProcessKillChannel(r chan steps.Result)

RemoveProcessKillChannel removes a provided channel from the process kill slice.

func (*Context) RunTask

func (c *Context) RunTask(n string) chan steps.Result

RunTask runs a task.

func (*Context) SetWorkingDirectory added in v0.2.0

func (c *Context) SetWorkingDirectory(wd string)

SetWorkingDirectory sets the context's working directory, including settings its original working directory.

func (*Context) UpdateWorkingDirectory added in v0.2.0

func (c *Context) UpdateWorkingDirectory(wd string)

UpdateWorkingDirectory updates the context's working directory.

func (*Context) WorkingDirectory added in v0.2.0

func (c *Context) WorkingDirectory() string

WorkingDirectory returns the context's working directory.

Directories

Path Synopsis
cmd
gobl command
The gobl command simply calls "go run gobl.go ..." in the working directory.
The gobl command simply calls "go run gobl.go ..." in the working directory.
init command
init initializes an existing or empty directory as a gobl project
init initializes an existing or empty directory as a gobl project
internal
test command
pkg

Jump to

Keyboard shortcuts

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