diff options
Diffstat (limited to 'pkg/config/lib/hg/hg.go')
| -rw-r--r-- | pkg/config/lib/hg/hg.go | 32 | 
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/config/lib/hg/hg.go b/pkg/config/lib/hg/hg.go new file mode 100644 index 0000000..d06e5aa --- /dev/null +++ b/pkg/config/lib/hg/hg.go @@ -0,0 +1,32 @@ +package hg + +import ( +	_ "embed" +	"go.nc0.fr/svgu/pkg/config" +	"go.starlark.net/starlark" +	"go.starlark.net/starlarkstruct" +	"sync" +) + +var ( +	once = sync.Once{} +	hg   = starlark.StringDict{} +	//go:embed hg.star +	hgFile string +	hgErr  error +) + +// LoadHgModule loads the Mercurial module. +func LoadHgModule(t *starlark.Thread) (starlark.StringDict, error) { +	once.Do(func() { +		env := starlark.StringDict{ +			"module": starlark.NewBuiltin("module", +				config.InternModule), +			"make_module": starlark.NewBuiltin("mod", +				starlarkstruct.MakeModule), +		} +		hg, hgErr = starlark.ExecFile(t, "hg.star", hgFile, env) +	}) + +	return hg, hgErr +}  | 
