gapi: Add a prefix variable in case we want to namespace on disk

This could get passed through to use as a module download path.
This commit is contained in:
James Shubin
2018-11-16 22:24:39 -05:00
parent 433ffa05a5
commit cd7711bdfe
4 changed files with 8 additions and 1 deletions

View File

@@ -50,6 +50,7 @@ type Data struct {
Noop bool
NoConfigWatch bool
NoStreamWatch bool
Prefix string
Debug bool
Logf func(format string, v ...interface{})
// NOTE: we can add more fields here if needed by GAPI endpoints

View File

@@ -38,6 +38,9 @@ type Pos struct {
// InterpolateInfo contains some information passed around during interpolation.
// TODO: rename to Info if this is moved to its own package.
type InterpolateInfo struct {
// Prefix used for path namespacing if required.
Prefix string
// Debug represents if we're running in debug mode or not.
Debug bool
@@ -73,7 +76,8 @@ func InterpolateStr(str string, pos *Pos, info *InterpolateInfo) (interfaces.Exp
}
transformInfo := &InterpolateInfo{
Debug: info.Debug,
Prefix: info.Prefix,
Debug: info.Debug,
Logf: func(format string, v ...interface{}) {
info.Logf("transform: "+format, v...)
},

View File

@@ -47,6 +47,7 @@ type Lang struct {
Input io.Reader // os.Stdin or anything that satisfies this interface
Hostname string
World engine.World
Prefix string
Debug bool
Logf func(format string, v ...interface{})

View File

@@ -481,6 +481,7 @@ func (obj *Main) Run() error {
//NoWatch: obj.NoWatch,
NoConfigWatch: obj.NoConfigWatch,
NoStreamWatch: obj.NoStreamWatch,
Prefix: fmt.Sprintf("%s/", path.Join(prefix, "gapi")),
Debug: obj.Flags.Debug,
Logf: func(format string, v ...interface{}) {
log.Printf("gapi: "+format, v...)