github.com/ssube/gitlab-ci-multi-runner@v1.2.1-0.20160607142738-b8d1285632e6/common/command.go (about)

     1  package common
     2  
     3  import (
     4  	log "github.com/Sirupsen/logrus"
     5  	"github.com/codegangsta/cli"
     6  	"gitlab.com/ayufan/golang-cli-helpers"
     7  )
     8  
     9  var commands []cli.Command
    10  
    11  type Commander interface {
    12  	Execute(c *cli.Context)
    13  }
    14  
    15  func RegisterCommand(command cli.Command) {
    16  	log.Debugln("Registering", command.Name, "command...")
    17  	commands = append(commands, command)
    18  }
    19  
    20  func RegisterCommand2(name, usage string, data Commander, flags ...cli.Flag) {
    21  	RegisterCommand(cli.Command{
    22  		Name:   name,
    23  		Usage:  usage,
    24  		Action: data.Execute,
    25  		Flags:  append(flags, clihelpers.GetFlagsFromStruct(data)...),
    26  	})
    27  }
    28  
    29  func GetCommands() []cli.Command {
    30  	return commands
    31  }