Kar
Kar is a simple utility that helps you create run [Kargar](https://github.com/omeid/kargar) builds from CLI.
To allow, co-existence of build file and your Go project code and to insure it
is properly isolated, kar is guarded with a build build constraint, kar
; to
properly leverage Go tooling's caching mechanism and avoid any issues with stale
cache objects, the task runner, cmd/kar
uses it's own pkgdir
($GOPATH/pkg/$GOOS_$GOARCH_kar
).
Install
Requires Go 1.5.
go install github.com/omeid/kar/cmd/kar
Example
$ cat demo_kar.go
// +build kar
// Pay attention at the build tag. Kar builds your project with the build tag `kar`
// which allows you the isolation of your _build code_ and as a result, dependencies
// from your main code.
package main
import (
"github.com/omeid/gonzo/context"
"github.com/omeid/kargar"
"github.com/omeid/kargar/kar"
)
// You must put your task definations inside an init.
// Read more about the order of init functions and Package Initialization
// at https://golang.org/ref/spec#Package_initialization
func init() {
kar.Run(func(build *kargar.Build) error {
return build.Add(
kargar.Task{
Name: "say-hello",
Usage: "This tasks is self-documented, it says hello for every second.",
Action: func(ctx context.Context) error {
ctx.Info("Hello!")
return nil
},
})
})
}
$ kar install # build and cache the dependencies.
$ kar say-hello #run task say-hello
INFO[0000] [say-hello]
INFO[0000] Hello! task=say-hello
#TODO: