gopp/tool.go

29 lines
508 B
Go
Raw Permalink Normal View History

2024-02-26 00:22:09 +03:00
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())
2024-02-26 00:22:09 +03:00
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))
2024-02-26 00:22:09 +03:00
if err != nil {
log.Println("pp error:", err)
continue
}
fmt.Print(str)
}
})