kar

package module
v0.0.0-...-e76773e Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 9 Imported by: 0

README

Kar GoDoc

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:

  • Finish this doc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(setup func(b *kargar.Build) error, cleanup func(int))

Run setups a build and runs the listed tasks and cancels the build on a SIGTREM or INTERRUPT. It also calls os.Exit with appropriate code.

Types

This section is empty.

Directories

Path Synopsis
cmd
kar

Jump to

Keyboard shortcuts

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