From 3c0c2a3cb45c86e5435717d8e91a9d15750d47f4 Mon Sep 17 00:00:00 2001 From: h4ckm310n Date: Fri, 31 May 2024 11:47:33 +0800 Subject: [PATCH] [fix] Handle "--help" before parsing srcPath - Fix the problem that Go extractor wrongly handles "--help" argument as a source path --- language/go/extractor/src/cli/helper.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/language/go/extractor/src/cli/helper.go b/language/go/extractor/src/cli/helper.go index d665b8c8..79f6d610 100644 --- a/language/go/extractor/src/cli/helper.go +++ b/language/go/extractor/src/cli/helper.go @@ -24,6 +24,10 @@ func parseExtractorRunningParams(args []string) *extractionConf { usage() os.Exit(2) } + if args[1] == "-h" || args[1] == "--help" { + usage() + os.Exit(0) + } configArgs := strings.Split(strings.Join(args[1:], " "), " ") srcPath, err := filepath.Abs(configArgs[len(configArgs)-1]) @@ -42,9 +46,6 @@ func parseExtractorRunningParams(args []string) *extractionConf { for i := 0; i < len(configArgs)-1 && strings.HasPrefix(configArgs[i], "-"); i++ { arg := configArgs[i] switch arg { - case "-h", "--help": - usage() - os.Exit(0) case "-exconfig", "-ex": handleExtractionArg(configArgs, &i, extractionConfig) case "-o", "-output", "-dbpath":