Skip to content

Commit 1e2bdd8

Browse files
committed
Add --identify-environment flag
1 parent 67afbee commit 1e2bdd8

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222

2323
func usage() {
2424
fmt.Fprintf(os.Stderr,
25-
`%s is a wrapper script that installs dependencies and calls the extractor.
25+
`%s is a wrapper script that installs dependencies and calls the extractor, or if '--identify-environment'
26+
is passed then it produces a file 'environment.json' which specifies what go version is needed.
2627
2728
When LGTM_SRC is not set, the script installs dependencies as described below, and then invokes the
2829
extractor in the working directory.
@@ -601,12 +602,7 @@ func extract(depMode DependencyInstallerMode, modMode ModMode) {
601602
}
602603
}
603604

604-
func main() {
605-
if len(os.Args) > 1 {
606-
usage()
607-
os.Exit(2)
608-
}
609-
605+
func installDependenciesAndBuild() {
610606
log.Printf("Autobuilder was built with %s, environment has %s\n", runtime.Version(), getEnvGoVersion())
611607

612608
srcdir := getSourceDir()
@@ -692,3 +688,18 @@ func main() {
692688

693689
extract(depMode, modMode)
694690
}
691+
692+
func identifyEnvironment() {
693+
694+
}
695+
696+
func main() {
697+
if len(os.Args) == 0 {
698+
installDependenciesAndBuild()
699+
} else if len(os.Args) == 2 && os.Args[1] == "--identify-environment" {
700+
identifyEnvironment()
701+
} else {
702+
usage()
703+
os.Exit(2)
704+
}
705+
}

0 commit comments

Comments
 (0)