func printInferredArguments(out *output.Output) {
	if out == nil {
		return
	}
	block := out.Block(output.Line(output.EmojiLightbulb, output.StyleItalic, "Inferred arguments"))
	block.Writef("repo: %s", lsifUploadFlags.repo)
	block.Writef("commit: %s", lsifUploadFlags.commit)
	block.Writef("root: %s", lsifUploadFlags.root)
	block.Writef("file: %s", lsifUploadFlags.file)
	block.Writef("indexer: %s", lsifUploadFlags.indexer)
	block.Close()
}
printInferredArguments prints a block showing the effective values of flags that are
inferrably defined. This function is called on all paths except for -json uploads. This
function no-ops if the given output object is nil.
package main
import (
	"encoding/base64"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"net/url"
	"os"
	"strings"
	"time"
	"github.com/pkg/browser"
	"github.com/sourcegraph/sourcegraph/lib/codeintel/upload"
	"github.com/sourcegraph/sourcegraph/lib/output"
	"github.com/sourcegraph/src-cli/internal/api"
)
func init() {
	usage := `
Examples:
  Upload an LSIF dump with explicit repo, commit, and upload files:
    	$ src lsif upload -repo=FOO -commit=BAR -file=dump.lsif
  Upload an LSIF dump for a subproject:
    	$ src lsif upload -root=cmd/
  Upload an LSIF dump when lsifEnforceAuth is enabled:
    	$ src lsif upload -github-token=BAZ
  Upload an LSIF dump when the LSIF indexer does not not declare a tool name.
    	$ src lsif upload -indexer=lsif-elixir
`
	lsifCommands = append(lsifCommands, &command{
		flagSet: lsifUploadFlagSet,
		handler: handleLSIFUpload,
		usageFunc: func() {
			fmt.Fprintf(flag.CommandLine.Output(), "Usage of 'src lsif %s':\n", lsifUploadFlagSet.Name())
			lsifUploadFlagSet.PrintDefaults()
			fmt.Println(usage)
		},
	})
}
func handleLSIFUpload(args []string) error {
	err := parseAndValidateLSIFUploadFlags(args)
	out := lsifUploadOutput()
	if !lsifUploadFlags.json {
		if out != nil {
			printInferredArguments(out)
		} else {
			printInferredArguments(emergencyOutput())
		}
	}
	if err != nil {
		return handleLSIFUploadError(nil, err)
	}
	client := api.NewClient(api.ClientOpts{
		Out:   io.Discard,
		Flags: lsifUploadFlags.apiFlags,
	})
	uploadID, err := upload.UploadIndex(lsifUploadFlags.file, client, lsifUploadOptions(out))
	if err != nil {
		return handleLSIFUploadError(out, err)
	}
	uploadURL, err := makeLSIFUploadURL(uploadID)
	if err != nil {
		return err
	}
	if lsifUploadFlags.json {
		serialized, err := json.Marshal(map[string]interface{}{
			"repo":      lsifUploadFlags.repo,
			"commit":    lsifUploadFlags.commit,
			"root":      lsifUploadFlags.root,
			"file":      lsifUploadFlags.file,
			"indexer":   lsifUploadFlags.indexer,
			"uploadId":  uploadID,
			"uploadUrl": uploadURL,
		})
		if err != nil {
			return err
		}
		fmt.Println(string(serialized))
	} else {
		if out == nil {
			out = emergencyOutput()
		}
		out.WriteLine(output.Linef(output.EmojiLightbulb, output.StyleItalic, "View processing status at %s", uploadURL))
	}
	if lsifUploadFlags.open {
		if err := browser.OpenURL(uploadURL); err != nil {
			return err
		}
	}
	return nil
}
func lsifUploadOutput() (out *output.Output) {
	if lsifUploadFlags.json || lsifUploadFlags.noProgress || lsifUploadFlags.verbosity > 0 {
		return nil
	}
	return output.NewOutput(flag.CommandLine.Output(), output.OutputOpts{
		Verbose: true,
	})
}
func lsifUploadOptions(out *output.Output) upload.UploadOptions {
	var associatedIndexID *int
	if lsifUploadFlags.associatedIndexID != -1 {
		associatedIndexID = &lsifUploadFlags.associatedIndexID
	}
	logger := upload.NewRequestLogger(
		os.Stdout,
		upload.RequestLoggerVerbosity(lsifUploadFlags.verbosity),
	)
	return upload.UploadOptions{
		UploadRecordOptions: upload.UploadRecordOptions{
			Repo:              lsifUploadFlags.repo,
			Commit:            lsifUploadFlags.commit,
			Root:              lsifUploadFlags.root,
			Indexer:           lsifUploadFlags.indexer,
			AssociatedIndexID: associatedIndexID,
		},
		SourcegraphInstanceOptions: upload.SourcegraphInstanceOptions{
			SourcegraphURL:      cfg.Endpoint,
			AccessToken:         cfg.AccessToken,
			AdditionalHeaders:   cfg.AdditionalHeaders,
			MaxRetries:          5,
			RetryInterval:       time.Second,
			Path:                lsifUploadFlags.uploadRoute,
			GitHubToken:         lsifUploadFlags.gitHubToken,
			MaxPayloadSizeBytes: lsifUploadFlags.maxPayloadSizeMb * 1000 * 1000,
		},
		OutputOptions: upload.OutputOptions{
			Output: out,
			Logger: logger,
		},
	}
}