taskforce

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MIT Imports: 4 Imported by: 2

README

TaskForce

a simple, functional task runner without the plugin nonsense!

package main

import (
	"fmt"
	"os"

	"github.com/cjtoolkit/taskforce"
)

func task() *taskforce.TaskForce {
	tf := taskforce.InitTaskForce()

	tf.Register("hello", func() {
		fmt.Println("Hello,")
	})

	tf.Register("world", func() {
		fmt.Println("World.")
	})

	tf.Register("echo-world", func() {
		tf.ExecCmd("echo", "world")
	})

	tf.Register("both", func() {
		tf.Run("hello", "world")
	})

	return tf
}

func main() {
	task().Run(os.Args[1:]...)
}

Documentation

Overview

TaskForce, a simple, functional task runner without the plugin nonsense!

package main

import (
	"fmt"
	"os"

	"github.com/cjtoolkit/taskforce"
)

func task() *taskforce.TaskForce {
	tf := taskforce.InitTaskForce()

	tf.Register("hello", func() {
		fmt.Println("Hello,")
	})

	tf.Register("world", func() {
		fmt.Println("World.")
	})

	tf.Register("echo-world", func() {
		tf.ExecCmd("echo", "world")
	})

	tf.Register("both", func() {
		tf.Run("hello", "world")
	})

	return tf
}

func main() {
	task().Run(os.Args[1:]...)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskForce

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

func InitTaskForce

func InitTaskForce() *TaskForce

Create new instance of TaskForce

func (*TaskForce) CheckError

func (tf *TaskForce) CheckError(err error)

Check Error, will panic if there is an error.

func (*TaskForce) ExecCmd

func (tf *TaskForce) ExecCmd(name string, args ...string)

Execute Terminal Command, will panic if there is error with the command.

func (*TaskForce) Register

func (tf *TaskForce) Register(name string, task func())

Register Task to TaskForce, has no effect after first run.

Not concurrent safe.

func (*TaskForce) Run

func (tf *TaskForce) Run(names ...string)

Run a selected task.

Non concurrent safe on first run, but is concurrent safe after first run

Note: will recover from error, on first run.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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