func randomID() (string, error) {
	return basex.Encode(strconv.Itoa(seededRand.Int()))
}
randomID generates a random ID to be used for identifiers in tasks.
package ui
import (
	"context"
	"encoding/json"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"time"
	"github.com/dineshappavoo/basex"
	"github.com/sourcegraph/src-cli/internal/batches"
	"github.com/sourcegraph/src-cli/internal/batches/executor"
	"github.com/sourcegraph/src-cli/internal/batches/graphql"
	"github.com/sourcegraph/src-cli/internal/batches/workspace"
	batcheslib "github.com/sourcegraph/sourcegraph/lib/batches"
	"github.com/sourcegraph/sourcegraph/lib/batches/git"
)
var _ ExecUI = &JSONLines{}
type JSONLines struct{}
func (ui *JSONLines) ParsingBatchSpec() {
	logOperationStart(batcheslib.LogEventOperationParsingBatchSpec, &batcheslib.ParsingBatchSpecMetadata{})
}
func (ui *JSONLines) ParsingBatchSpecSuccess() {
	logOperationSuccess(batcheslib.LogEventOperationParsingBatchSpec, &batcheslib.ParsingBatchSpecMetadata{})
}
func (ui *JSONLines) ParsingBatchSpecFailure(err error) {
	logOperationFailure(batcheslib.LogEventOperationParsingBatchSpec, &batcheslib.ParsingBatchSpecMetadata{Error: err.Error()})
}
func (ui *JSONLines) ResolvingNamespace() {
	logOperationStart(batcheslib.LogEventOperationResolvingNamespace, &batcheslib.ResolvingNamespaceMetadata{})
}
func (ui *JSONLines) ResolvingNamespaceSuccess(namespace string) {
	logOperationSuccess(batcheslib.LogEventOperationResolvingNamespace, &batcheslib.ResolvingNamespaceMetadata{NamespaceID: namespace})
}
func (ui *JSONLines) PreparingContainerImages() {
	logOperationStart(batcheslib.LogEventOperationPreparingDockerImages, &batcheslib.PreparingDockerImagesMetadata{})
}
func (ui *JSONLines) PreparingContainerImagesProgress(done, total int) {
	logOperationProgress(batcheslib.LogEventOperationPreparingDockerImages, &batcheslib.PreparingDockerImagesMetadata{Done: done, Total: total})
}
func (ui *JSONLines) PreparingContainerImagesSuccess() {
	logOperationSuccess(batcheslib.LogEventOperationPreparingDockerImages, &batcheslib.PreparingDockerImagesMetadata{})
}
func (ui *JSONLines) DeterminingWorkspaceCreatorType() {
	logOperationStart(batcheslib.LogEventOperationDeterminingWorkspaceType, &batcheslib.DeterminingWorkspaceTypeMetadata{})
}
func (ui *JSONLines) DeterminingWorkspaceCreatorTypeSuccess(wt workspace.CreatorType) {
	var t string
	switch wt {
	case workspace.CreatorTypeVolume:
		t = "VOLUME"
	case workspace.CreatorTypeBind:
		t = "BIND"
	}
	logOperationSuccess(batcheslib.LogEventOperationDeterminingWorkspaceType, &batcheslib.DeterminingWorkspaceTypeMetadata{Type: t})
}
func (ui *JSONLines) ResolvingRepositories() {
	logOperationStart(batcheslib.LogEventOperationResolvingRepositories, &batcheslib.ResolvingRepositoriesMetadata{})
}
func (ui *JSONLines) ResolvingRepositoriesDone(repos []*graphql.Repository, unsupported batches.UnsupportedRepoSet, ignored batches.IgnoredRepoSet) {
	logOperationSuccess(batcheslib.LogEventOperationResolvingRepositories, &batcheslib.ResolvingRepositoriesMetadata{
		Unsupported: len(unsupported),
		Ignored:     len(ignored),
		Count:       len(repos),
	})
}
func (ui *JSONLines) DeterminingWorkspaces() {
	logOperationStart(batcheslib.LogEventOperationDeterminingWorkspaces, &batcheslib.DeterminingWorkspacesMetadata{})
}
func (ui *JSONLines) DeterminingWorkspacesSuccess(num int) {
	logOperationSuccess(batcheslib.LogEventOperationDeterminingWorkspaces, &batcheslib.DeterminingWorkspacesMetadata{Count: num})
}
func (ui *JSONLines) CheckingCache() {
	logOperationStart(batcheslib.LogEventOperationCheckingCache, &batcheslib.CheckingCacheMetadata{})
}
func (ui *JSONLines) CheckingCacheSuccess(cachedSpecsFound int, tasksToExecute int) {
	logOperationSuccess(batcheslib.LogEventOperationCheckingCache, &batcheslib.CheckingCacheMetadata{
		CachedSpecsFound: cachedSpecsFound,
		TasksToExecute:   tasksToExecute,
	})
}
func (ui *JSONLines) ExecutingTasks(verbose bool, parallelism int) executor.TaskExecutionUI {
	return &taskExecutionJSONLines{verbose: verbose, parallelism: parallelism}
}
func (ui *JSONLines) ExecutingTasksSkippingErrors(err error) {
	logOperationSuccess(batcheslib.LogEventOperationExecutingTasks, &batcheslib.ExecutingTasksMetadata{
		Skipped: true,
		Error:   err.Error(),
	})
}
func (ui *JSONLines) LogFilesKept(files []string) {
	for _, path := range files {
		logOperationSuccess(batcheslib.LogEventOperationLogFileKept, &batcheslib.LogFileKeptMetadata{Path: path})
	}
}
func (ui *JSONLines) NoChangesetSpecs() {
	ui.UploadingChangesetSpecsSuccess([]graphql.ChangesetSpecID{})
}
func (ui *JSONLines) UploadingChangesetSpecs(num int) {
	logOperationStart(batcheslib.LogEventOperationUploadingChangesetSpecs, &batcheslib.UploadingChangesetSpecsMetadata{
		Done:  0,
		Total: num,
	})
}
func (ui *JSONLines) UploadingChangesetSpecsProgress(done, total int) {
	logOperationProgress(batcheslib.LogEventOperationUploadingChangesetSpecs, &batcheslib.UploadingChangesetSpecsMetadata{
		Done:  done,
		Total: total,
	})
}
func (ui *JSONLines) UploadingChangesetSpecsSuccess(ids []graphql.ChangesetSpecID) {
	sIDs := make([]string, len(ids))
	for i, id := range ids {
		sIDs[i] = string(id)
	}
	logOperationSuccess(batcheslib.LogEventOperationUploadingChangesetSpecs, &batcheslib.UploadingChangesetSpecsMetadata{
		Done:  len(ids),
		Total: len(ids),
		IDs:   sIDs,
	})
}
func (ui *JSONLines) CreatingBatchSpec() {
	logOperationStart(batcheslib.LogEventOperationCreatingBatchSpec, &batcheslib.CreatingBatchSpecMetadata{})
}
func (ui *JSONLines) CreatingBatchSpecSuccess(batchSpecURL string) {
	logOperationSuccess(batcheslib.LogEventOperationCreatingBatchSpec, &batcheslib.CreatingBatchSpecMetadata{
		PreviewURL: batchSpecURL,
	})
}
func (ui *JSONLines) CreatingBatchSpecError(err error) error {
	logOperationFailure(batcheslib.LogEventOperationCreatingBatchSpec, &batcheslib.CreatingBatchSpecMetadata{})
	return err
}
func (ui *JSONLines) PreviewBatchSpec(batchSpecURL string) {
}
func (ui *JSONLines) ApplyingBatchSpec() {
	logOperationStart(batcheslib.LogEventOperationApplyingBatchSpec, &batcheslib.ApplyingBatchSpecMetadata{})
}
func (ui *JSONLines) ApplyingBatchSpecSuccess(batchChangeURL string) {
	logOperationSuccess(batcheslib.LogEventOperationApplyingBatchSpec, &batcheslib.ApplyingBatchSpecMetadata{BatchChangeURL: batchChangeURL})
}
func (ui *JSONLines) ExecutionError(err error) {
	logOperationFailure(batcheslib.LogEventOperationBatchSpecExecution, &batcheslib.BatchSpecExecutionMetadata{Error: err.Error()})
}
type taskExecutionJSONLines struct {
	verbose     bool
	parallelism int
	linesTasks map[*executor.Task]batcheslib.JSONLinesTask
}
var seededRand = rand.New(rand.NewSource(time.Now().UTC().UnixNano()))