You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: main.go
    path of file: ./repos/cockroach/pkg/sql/opt/optgen/cmd/optgen
    
    the code of the file until where you have to start completion: // Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

p
    
func (g *optgen) run(args ...string) bool {
	// Parse command line.
	g.cmdLine = flag.NewFlagSet("optgen", flag.ContinueOnError)
	g.cmdLine.SetOutput(g.stdErr)
	g.cmdLine.Usage = g.usage
	g.cmdLine.String("out", "", "output file name of generated code")
	err := g.cmdLine.Parse(args)
	if err != nil {
		return false
	}

	// Get remaining args after any flags have been parsed.
	args = g.cmdLine.Args()
	if len(args) < 2 {
		g.cmdLine.Usage()
		g.reportError(errInvalidArgCount)
		return false
	}

	cmd := args[0]
	sources := g.cmdLine.Args()[1:]

	runValidate := true
	switch cmd {
	case "compile":
	case "explorer":
	case "exprs":
	case "factory":
	case "ops":
	case "rulenames":

	case "execfactory", "execexplain", "execplangist":
		runValidate = false

	default:
		g.cmdLine.Usage()
		g.reportError(errUnrecognizedCommand)
		return false
	}

	// Set glob resolver if it hasn't yet been set.
	if g.globResolver == nil {
		g.globResolver = filepath.Glob
	}

	// Map sources to a set of files using the glob resolver.
	files := make([]string, 0, len(sources))
	for _, source := range sources {
		matches, err := g.globResolver(source)
		if err != nil {
			g.reportError(err)
			return false
		}
		files = append(files, matches...)
	}

	// Sort the files so that output is stable.
	sort.Strings(files)

	compiler := lang.NewCompiler(files...)

	if g.fileResolver != nil {
		// Use caller-provided custom file resolver.
		compiler.SetFileResolver(g.fileResolver)
	}

	var errors []error
	compiled := compiler.Compile()
	if compiled == nil {
		errors = compiler.Errors()
	} else if runValidate {
		// Do additional validation checks.
		var v validator
		errors = v.validate(compiled)
	}

	if errors != nil {
		for i, err := range errors {
			if i >= g.maxErrors-1 {
				count := len(errors) - g.maxErrors + 1
				if count > 1 {
					fmt.Fprintf(g.stdErr, "... too many errors (%d more)\n", count)
					break
				}
			}

			fmt.Fprintf(g.stdErr, "%v\n", err)
		}
		return false
	}

	switch cmd {
	case "compile":
		err = g.writeOutputFile([]byte(compiled.String()))

	case "explorer":
		var gen explorerGen
		err = g.generate(compiled, gen.generate)

	case "exprs":
		var gen exprsGen
		err = g.generate(compiled, gen.generate)

	case "factory":
		var gen factoryGen
		err = g.generate(compiled, gen.generate)

	case "ops":
		var gen opsGen
		err = g.generate(compiled, gen.generate)

	case "rulenames":
		var gen ruleNamesGen
		err = g.generate(compiled, gen.generate)

	case "execfactory":
		var gen execFactoryGen
		err = g.generate(compiled, gen.generate)

	case "execexplain":
		var gen execExplainGen
		err = g.generate(compiled, gen.generate)

	case "execplangist":
		var gen execPlanGistGen
		err = g.generate(compiled, gen.generate)
	}

	if err != nil {
		g.reportError(err)
		return false
	}
	return true
}