package tpp import ( //"github.com/d5/tengo/v2" "github.com/d5/tengo/v2/stdlib" "vultras.su/core/cli/mtool" //"fmt" "os" "log" "path/filepath" "context" ) var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){ t := NewTengo(). SetPreCompile(func(s *Script){ s.SetImports(stdlib.GetModuleMap( stdlib.AllModuleNames()..., )) s.EnableFileImport(true) s.SetImportDir(".") }) pp := New(t) filePaths := flags.Parse() for _, filePath := range filePaths { pth := filepath.FromSlash(filePath) bts, err := os.ReadFile(pth) if err != nil { log.Println("read error:", err) continue } out, err := pp.Process( context.Background(), true, pth, bts, ) if err != nil { log.Println("pp error:", err) continue } os.Stdout.Write(out) } })