github.com/n3integration/conseil@v0.1.1/actions/actions.go (about)

     1  package actions
     2  
     3  import (
     4  	"strings"
     5  	"sync"
     6  	"text/template"
     7  
     8  	"gopkg.in/urfave/cli.v1"
     9  
    10  	"github.com/n3integration/conseil"
    11  )
    12  
    13  var registry = struct {
    14  	actions []cli.Command
    15  	mu      sync.Mutex
    16  }{
    17  	actions: make([]cli.Command, 0),
    18  }
    19  
    20  func register(command cli.Command) {
    21  	registry.mu.Lock()
    22  	defer registry.mu.Unlock()
    23  
    24  	registry.actions = append(registry.actions, command)
    25  }
    26  
    27  func GetCommands() []cli.Command {
    28  	return registry.actions
    29  }
    30  
    31  func parseTemplates() *template.Template {
    32  	templates := template.New("t")
    33  	for _, f := range conseil.AssetNames() {
    34  		if strings.HasSuffix(f, ".tpl") {
    35  			templates = templates.New(f)
    36  			templates.Parse(string(conseil.MustAsset(f)))
    37  		}
    38  	}
    39  	return templates
    40  }