sourcegraph/internal/cmd/precise-code-intel-tester/main.go
Camden Cheek 16dfe4c1a3
Enable varcheck lint (#18997)
* Use defined trace constant

* Remove unused variables from precise-code-intel-tester

Auth variables appear to have been replaced by a token, and the test
client appears to have been replaced by raw HTTP requests.

* Remove unused query format string

It appears this was never used since the commit that added it (9709401)
only referenced it once.

* Remove unused constant

* Enable varcheck lint
2021-03-10 07:35:29 -07:00

77 lines
2.1 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/sourcegraph/sourcegraph/internal/env"
)
var (
endpoint = env.Get("SOURCEGRAPH_BASE_URL", "http://127.0.0.1:3080", "Sourcegraph frontend endpoint")
token = env.Get("SOURCEGRAPH_SUDO_TOKEN", "", "Access token")
// Flags
indexDir string
numConcurrentUploads int
numConcurrentRequests int
checkQueryResult bool
queryReferencesOfReferences bool
// Entrypoints
commands = map[string]func() error{
"upload": uploadCommand,
"query": queryCommand,
}
)
func main() {
flag.StringVar(&indexDir, "indexDir", "./testdata/indexes", "The location of the testdata directory") // Assumes running from this directory
flag.IntVar(&numConcurrentUploads, "numConcurrentUploads", 5, "The maximum number of concurrent uploads")
flag.IntVar(&numConcurrentRequests, "numConcurrentRequests", 5, "The maximum number of concurrent requests")
flag.BoolVar(&checkQueryResult, "checkQueryResult", true, "Whether to confirm query results are correct")
flag.BoolVar(&queryReferencesOfReferences, "queryReferencesOfReferences", false, "Whether to perform reference operations on test case references")
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "subcommand (one of %s) is required\n", commandNameList())
os.Exit(1)
}
command, ok := commands[os.Args[1]]
if !ok {
fmt.Fprintf(os.Stderr, "subcommand (one of %s) is required\n", commandNameList())
os.Exit(1)
}
if err := flag.CommandLine.Parse(os.Args[2:]); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
if err := command(); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}
// commandNameList returns a comma-separated list of valid command names.
func commandNameList() string {
var commandNames []string
for name := range commands {
commandNames = append(commandNames, name)
}
var parts []string
for i, name := range commandNames {
if i == len(commandNames)-1 {
name = fmt.Sprintf("or %s", name)
}
parts = append(parts, name)
}
return strings.Join(parts, ", ")
}