[refactoring] cli: add -e flag
This commit is contained in:
parent
f12218d083
commit
7fc23cc1de
@ -3,12 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ var withFreeFloating *bool
|
|||||||
var showResolvedNs *bool
|
var showResolvedNs *bool
|
||||||
var printBack *bool
|
var printBack *bool
|
||||||
var printPath *bool
|
var printPath *bool
|
||||||
|
var printErrors *bool
|
||||||
var printExecTime *bool
|
var printExecTime *bool
|
||||||
|
|
||||||
type file struct {
|
type file struct {
|
||||||
@ -52,6 +54,7 @@ func main() {
|
|||||||
showResolvedNs = flag.Bool("r", false, "resolve names")
|
showResolvedNs = flag.Bool("r", false, "resolve names")
|
||||||
printBack = flag.Bool("pb", false, "print AST back into the parsed file")
|
printBack = flag.Bool("pb", false, "print AST back into the parsed file")
|
||||||
printPath = flag.Bool("p", false, "print filepath")
|
printPath = flag.Bool("p", false, "print filepath")
|
||||||
|
printErrors = flag.Bool("e", false, "print errors")
|
||||||
dump = flag.Bool("d", false, "dump")
|
dump = flag.Bool("d", false, "dump")
|
||||||
flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]")
|
flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]")
|
||||||
flag.StringVar(&phpVersion, "phpver", "7.4", "php version")
|
flag.StringVar(&phpVersion, "phpver", "7.4", "php version")
|
||||||
@ -151,11 +154,13 @@ func printerWorker(r <-chan result) {
|
|||||||
counter++
|
counter++
|
||||||
|
|
||||||
if *printPath {
|
if *printPath {
|
||||||
fmt.Fprintf(os.Stdout, "==> [%d] %s\n", counter, res.path)
|
_, _ = io.WriteString(os.Stderr, "==> [" + strconv.Itoa(counter) + "] " + res.path + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range res.errors {
|
if *printErrors {
|
||||||
fmt.Fprintf(os.Stdout, "==> %s\n", e)
|
for _, e := range res.errors {
|
||||||
|
_, _ = io.WriteString(os.Stderr, "==> " + e.String() + "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *printBack {
|
if *printBack {
|
||||||
@ -171,7 +176,9 @@ func printerWorker(r <-chan result) {
|
|||||||
v := visitor.NewNamespaceResolver()
|
v := visitor.NewNamespaceResolver()
|
||||||
t := traverser.NewDFS(v)
|
t := traverser.NewDFS(v)
|
||||||
t.Traverse(res.rootNode)
|
t.Traverse(res.rootNode)
|
||||||
fmt.Printf("%+v", v.ResolvedNames)
|
for _, n := range v.ResolvedNames {
|
||||||
|
_, _ = io.WriteString(os.Stderr, "===> " + n + "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *dump == true {
|
if *dump == true {
|
||||||
|
Loading…
Reference in New Issue
Block a user