cli: add -noDump flug

This commit is contained in:
z7zmey 2018-06-05 12:22:36 +03:00
parent 22fe72467f
commit 876c5845d9

22
main.go
View File

@ -17,9 +17,11 @@ import (
var wg sync.WaitGroup var wg sync.WaitGroup
var usePhp5 *bool var usePhp5 *bool
var noDump *bool
func main() { func main() {
usePhp5 = flag.Bool("php5", false, "use PHP5 parserWorker") usePhp5 = flag.Bool("php5", false, "use PHP5 parserWorker")
noDump = flag.Bool("noDump", false, "disable dumping to stdout")
flag.Parse() flag.Parse()
pathCh := make(chan string) pathCh := make(chan string)
@ -85,17 +87,19 @@ func printer(result <-chan parser.Parser) {
fmt.Println(e) fmt.Println(e)
} }
nsResolver := visitor.NewNamespaceResolver() if !*noDump {
parserWorker.GetRootNode().Walk(nsResolver) nsResolver := visitor.NewNamespaceResolver()
parserWorker.GetRootNode().Walk(nsResolver)
dumper := visitor.Dumper{ dumper := visitor.Dumper{
Writer: os.Stdout, Writer: os.Stdout,
Indent: " | ", Indent: " | ",
Comments: parserWorker.GetComments(), Comments: parserWorker.GetComments(),
Positions: parserWorker.GetPositions(), Positions: parserWorker.GetPositions(),
NsResolver: nsResolver, NsResolver: nsResolver,
}
parserWorker.GetRootNode().Walk(dumper)
} }
parserWorker.GetRootNode().Walk(dumper)
wg.Done() wg.Done()
} }
} }