gopp/tool.go

29 lines
493 B
Go
Raw 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()
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(string(bts))
if err != nil {
log.Println("pp error:", err)
continue
}
fmt.Print(str)
}
})