cmd

package
v0.0.0-...-b863ece Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InternalActions = map[string]achieve.ActionProviderFunc{
	"github": github.Provider,
	"script": script.Provider,
}

InternalActions ...

View Source
var RootCmd = &cobra.Command{
	Use:   "achieve task",
	Short: "A modern tool for development task automation",
	Long:  ``,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		if len(args) > 0 && args[0] == "internal-plugin" {
			err := pluginCmd.RunE(pluginCmd, args[1:])
			if err != nil {
				return err
			}
		}

		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		taskName := "default"
		if len(args) > 0 {
			taskName = args[0]
		}

		if cfgFile == "" {
			cfgFile = ".Achievefile"
		}

		log.SetOutput(ioutil.Discard)

		rootCfg := DefaultConfig
		err := rootCfg.LoadPlugins()
		if err != nil {
			return err
		}

		config, err := achieve.LoadConfig(cfgFile)
		if err != nil {
			return err
		}

		ctx = NewContext(taskName, config)
		ctx.Providers = rootCfg.ActionProviderFactories()

		fmt.Printf("Executing Task %s\n", taskName)
		ctx.Execute()

		return nil
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type Config

type Config struct {
	Providers map[string]string
}
var DefaultConfig Config

func (*Config) ActionProviderFactories

func (c *Config) ActionProviderFactories() map[string]achieve.ActionProviderFactory

func (*Config) LoadPlugins

func (c *Config) LoadPlugins() error

type Context

type Context struct {
	Config    *achieve.Config
	Providers map[string]achieve.ActionProviderFactory
	// contains filtered or unexported fields
}

Context ...

func NewContext

func NewContext(task string, conf *achieve.Config) *Context

NewContext returns a new Context

func (*Context) Execute

func (ctx *Context) Execute()

Execute ...

Jump to

Keyboard shortcuts

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