gopp/tool.go

28 lines
508 B
Go

package pp
import (
"vultras.su/core/cli/mtool"
"fmt"
"os"
"log"
"path/filepath"
)
var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){
pp := NewPp(NewTengo())
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
}
str, err := pp.Process(pth, string(bts))
if err != nil {
log.Println("pp error:", err)
continue
}
fmt.Print(str)
}
})