cmd: parse the all php files in a path
This commit is contained in:
parent
4bef4fa26f
commit
cdd9a7f1bc
18
main.go
18
main.go
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/yookoala/realpath"
|
"github.com/yookoala/realpath"
|
||||||
"github.com/z7zmey/php-parser/parser"
|
"github.com/z7zmey/php-parser/parser"
|
||||||
@ -16,12 +17,21 @@ func main() {
|
|||||||
for _, path := range flag.Args() {
|
for _, path := range flag.Args() {
|
||||||
real, err := realpath.Realpath(path)
|
real, err := realpath.Realpath(path)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
fmt.Printf("==> %s\n", real)
|
|
||||||
|
|
||||||
src, _ := os.Open(string(real))
|
err = filepath.Walk(real, func(path string, f os.FileInfo, err error) error {
|
||||||
rootnode, comments, positions := parser.Parse(src, real)
|
if !f.IsDir() && filepath.Ext(path) == ".php" {
|
||||||
|
fmt.Printf("==> %s\n", path)
|
||||||
|
|
||||||
rootnode.Walk(dumper{" | ", comments, positions})
|
src, _ := os.Open(string(path))
|
||||||
|
parser.Parse(src, path)
|
||||||
|
nodes, comments, positions := parser.Parse(src, path)
|
||||||
|
|
||||||
|
visitor := dumper{" | ", comments, positions}
|
||||||
|
nodes.Walk(visitor)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
checkErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user