diff --git a/cmd/tx/main.go b/cmd/tx/main.go index f033634..9049c6b 100644 --- a/cmd/tx/main.go +++ b/cmd/tx/main.go @@ -152,6 +152,10 @@ func Main() { Aliases: []string{"w"}, Value: 5, }, + &cli.BoolFlag{ + Name: "silent", + Usage: "Whether to reduce verbosity of the output", + }, }, Action: func(c *cli.Context) error { cfg, err := config.LoadFromPaths( @@ -225,6 +229,7 @@ func Main() { Branch: c.String("branch"), All: c.Bool("all"), Workers: c.Int("workers"), + Silent: c.Bool("silent"), } if args.All && len(args.Languages) > 0 { @@ -369,6 +374,10 @@ func Main() { Aliases: []string{"w"}, Value: 5, }, + &cli.BoolFlag{ + Name: "silent", + Usage: "Whether to reduce verbosity of the output", + }, }, Action: func(c *cli.Context) error { cfg, err := config.LoadFromPaths(c.String("root-config"), @@ -420,6 +429,7 @@ func Main() { Branch: c.String("branch"), MinimumPercentage: c.Int("minimum-perc"), Workers: c.Int("workers"), + Silent: c.Bool("silent"), } if c.Bool("xliff") && c.Bool("json") { diff --git a/internal/txlib/pull.go b/internal/txlib/pull.go index 5c21ca6..93455e6 100644 --- a/internal/txlib/pull.go +++ b/internal/txlib/pull.go @@ -31,6 +31,7 @@ type PullCommandArguments struct { Branch string MinimumPercentage int Workers int + Silent bool } func PullCommand( @@ -48,11 +49,13 @@ func PullCommand( return cfgResources[i].GetAPv3Id() < cfgResources[j].GetAPv3Id() }) - fmt.Print("# Getting info about resources\n\n") + if !args.Silent { + fmt.Print("# Getting info about resources\n\n") + } filePullTaskChannel := make(chan *FilePullTask) var filePullTasks []*FilePullTask - pool := worker_pool.New(args.Workers, len(cfgResources)) + pool := worker_pool.New(args.Workers, len(cfgResources), args.Silent) for _, cfgResource := range cfgResources { pool.Add(&ResourcePullTask{cfgResource, api, args, filePullTaskChannel, cfg}) } @@ -71,6 +74,17 @@ func PullCommand( if pool.IsAborted { return errors.New("Aborted") } + if args.Silent { + var names []string + for _, cfgResource := range cfgResources { + names = append(names, fmt.Sprintf( + "%s.%s", + cfgResource.ProjectSlug, + cfgResource.ResourceSlug, + )) + } + fmt.Printf("Got info about resources: %s\n", strings.Join(names, ", ")) + } if len(filePullTasks) > 0 { sort.Slice(filePullTasks, func(i, j int) bool { @@ -83,8 +97,10 @@ func PullCommand( } }) - fmt.Print("\n# Pulling files\n\n") - pool = worker_pool.New(args.Workers, len(filePullTasks)) + if !args.Silent { + fmt.Print("\n# Pulling files\n\n") + } + pool = worker_pool.New(args.Workers, len(filePullTasks), args.Silent) for _, task := range filePullTasks { pool.Add(task) } @@ -94,6 +110,23 @@ func PullCommand( if pool.IsAborted { return errors.New("Aborted") } + if args.Silent { + var names []string + for _, filePullTask := range filePullTasks { + var languageCode string + if filePullTask.languageCode == "" { + languageCode = "source" + } else { + languageCode = filePullTask.languageCode + } + names = append(names, fmt.Sprintf( + "%s: %s", + filePullTask.cfgResource.ResourceSlug, + languageCode, + )) + } + fmt.Printf("Pulled files: %s\n", strings.Join(names, ", ")) + } } return nil @@ -114,7 +147,10 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { filePullTaskChannel := task.filePullTaskChannel cfg := task.cfg - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } send(fmt.Sprintf( "%s.%s - %s", cfgResource.ProjectSlug, @@ -122,7 +158,7 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { body, )) } - sendMessage("Getting info") + sendMessage("Getting info", false) localToRemoteLanguageMappings := makeLocalToRemoteLanguageMappings( *cfg, @@ -135,24 +171,27 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { var err error resource, err := txapi.GetResourceById(api, cfgResource.GetAPv3Id()) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } if resource == nil { - sendMessage(fmt.Sprintf( - "Resource %s.%s does not exist", - cfgResource.ProjectSlug, - cfgResource.ResourceSlug, - )) + sendMessage( + fmt.Sprintf( + "Resource %s.%s does not exist", + cfgResource.ProjectSlug, + cfgResource.ResourceSlug, + ), + true, + ) return } projectRelationship, err := resource.Fetch("project") if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -168,7 +207,7 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { stats, err = txapi.GetResourceStats(api, resource, nil) } if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -197,7 +236,7 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { // Local stuff err = checkFileFilter(cfgResource.FileFilter) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -279,7 +318,7 @@ func (task *ResourcePullTask) Run(send func(string), abort func()) { } } } - sendMessage("Done") + sendMessage("Done", false) } type FilePullTask struct { @@ -303,7 +342,10 @@ func (task *FilePullTask) Run(send func(string), abort func()) { filePath := task.filePath remoteToLocalLanguageMapping := task.remoteToLocalLanguageMappings - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } var code string if languageCode == "" { code = "source" @@ -320,17 +362,14 @@ func (task *FilePullTask) Run(send func(string), abort func()) { body, )) } - sendMessage("Pulling file") + sendMessage("Pulling file", false) if languageCode == "" { sourceFile := setFileTypeExtensions(args.FileType, cfgResource.SourceFile) _, err := os.Stat(sourceFile) if err == nil && args.DisableOverwrite { - sendMessage("Disable Overwrite is enabled, skipping") - if !args.Skip { - abort() - } + sendMessage("Disable Overwrite is enabled, skipping", false) return } @@ -341,14 +380,14 @@ func (task *FilePullTask) Run(send func(string), abort func()) { args.UseGitTimestamps, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } if shouldSkip { - sendMessage("Local file is newer than remote, skipping") + sendMessage("Local file is newer than remote, skipping", false) return } } @@ -368,10 +407,10 @@ func (task *FilePullTask) Run(send func(string), abort func()) { return err }, "Creating download job", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -389,10 +428,10 @@ func (task *FilePullTask) Run(send func(string), abort func()) { ) }, "", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -402,7 +441,7 @@ func (task *FilePullTask) Run(send func(string), abort func()) { if filePath != "" { // Remote language file exists and so does local if args.DisableOverwrite { - sendMessage("Disable overwrite enabled, skipping") + sendMessage("Disable overwrite enabled, skipping", false) return } } else { @@ -415,7 +454,7 @@ func (task *FilePullTask) Run(send func(string), abort func()) { if !args.All && (!stringSliceContains(args.Languages, remoteLanguageCode) && !stringSliceContains(args.Languages, localLanguageCode)) { - sendMessage("File was not found locally, skipping") + sendMessage("File was not found locally, skipping", false) return } filePath = strings.Replace( @@ -441,14 +480,14 @@ func (task *FilePullTask) Run(send func(string), abort func()) { args.Force, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } if shouldSkip { - sendMessage("Local file is newer than remote, skipping") + sendMessage("Local file is newer than remote, skipping", false) return } @@ -469,10 +508,10 @@ func (task *FilePullTask) Run(send func(string), abort func()) { return err }, "Creating download job", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -486,17 +525,17 @@ func (task *FilePullTask) Run(send func(string), abort func()) { return txapi.PollTranslationDownload(download, filePath) }, "", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } } - sendMessage("Done") + sendMessage("Done", false) } func shouldSkipDownload( diff --git a/internal/txlib/push.go b/internal/txlib/push.go index 48fe563..e558232 100644 --- a/internal/txlib/push.go +++ b/internal/txlib/push.go @@ -28,6 +28,7 @@ type PushCommandArguments struct { Branch string All bool Workers int + Silent bool } func PushCommand( @@ -50,9 +51,11 @@ func PushCommand( // Step 1: Resources - fmt.Print("# Getting info about resources\n\n") + if !args.Silent { + fmt.Print("# Getting info about resources\n\n") + } - pool := worker_pool.New(args.Workers, len(cfgResources)) + pool := worker_pool.New(args.Workers, len(cfgResources), args.Silent) sourceTaskChannel := make(chan *SourceFilePushTask) translationTaskChannel := make(chan *TranslationFileTask) targetLanguagesChannel := make(chan TargetLanguageMessage) @@ -113,38 +116,71 @@ func PushCommand( } if pool.IsAborted { - fmt.Println("Aborted") return errors.New("Aborted") } + if args.Silent { + var names []string + for _, cfgResource := range cfgResources { + names = append(names, fmt.Sprintf( + "%s.%s", + cfgResource.ProjectSlug, + cfgResource.ResourceSlug, + )) + } + fmt.Printf("Got info about resources: %s\n", strings.Join(names, ", ")) + } // Step 2: Create missing remote target languages + if len(targetLanguages) > 0 { - fmt.Print("\n# Create missing remote target languages\n\n") + if !args.Silent { + fmt.Print("\n# Create missing remote target languages\n\n") + } - pool = worker_pool.New(args.Workers, len(targetLanguages)) + pool = worker_pool.New(args.Workers, len(targetLanguages), args.Silent) for projectId, languages := range targetLanguages { sort.Slice(languages, func(i, j int) bool { return languages[i] < languages[j] }) - pool.Add(&LanguagePushTask{projects[projectId], languages}) + pool.Add(&LanguagePushTask{projects[projectId], languages, args}) } pool.Start() <-pool.Wait() if pool.IsAborted { - fmt.Println("Aborted") return errors.New("Aborted") } + if args.Silent { + var names []string + for projectId, languages := range targetLanguages { + parts := strings.Split(projectId, ":") + projectSlug := parts[1] + + var languageCodes []string + languageCodes = append(languageCodes, languages...) + names = append(names, fmt.Sprintf( + "%s: %s", + projectSlug, + strings.Join(languageCodes, ", "), + )) + } + fmt.Printf( + "Created missing remote target languages: %s\n", + strings.Join(names, ", "), + ) + } } // Step 3: SourceFiles if len(sourceFileTasks) > 0 { - fmt.Print("\n# Pushing source files\n\n") + if !args.Silent { + fmt.Print("\n# Pushing source files\n\n") + } sort.Slice(sourceFileTasks, func(i, j int) bool { return sourceFileTasks[i].resource.Id < sourceFileTasks[j].resource.Id }) - pool = worker_pool.New(args.Workers, len(sourceFileTasks)) + pool = worker_pool.New(args.Workers, len(sourceFileTasks), args.Silent) for _, sourceFileTask := range sourceFileTasks { pool.Add(sourceFileTask) } @@ -152,9 +188,20 @@ func PushCommand( <-pool.Wait() if pool.IsAborted { - fmt.Println("Aborted") return errors.New("Aborted") } + if args.Silent { + var names []string + for _, sourceFileTask := range sourceFileTasks { + parts := strings.Split(sourceFileTask.resource.Id, ":") + resourceSlug := parts[5] + names = append(names, resourceSlug) + } + fmt.Printf( + "Pushed source files for: %s\n", + strings.Join(names, ", "), + ) + } } // Step 4: Translations @@ -169,9 +216,11 @@ func PushCommand( return left.languageCode < right.languageCode } }) - fmt.Print("\n# Pushing translations\n\n") + if !args.Silent { + fmt.Print("\n# Pushing translations\n\n") + } - pool = worker_pool.New(args.Workers, len(translationFileTasks)) + pool = worker_pool.New(args.Workers, len(translationFileTasks), args.Silent) for _, translationFileTask := range translationFileTasks { pool.Add(translationFileTask) } @@ -179,9 +228,21 @@ func PushCommand( <-pool.Wait() if pool.IsAborted { - fmt.Println("Aborted") return errors.New("Aborted") } + if args.Silent { + var names []string + for _, translationFileTask := range translationFileTasks { + parts := strings.Split(translationFileTask.resource.Id, ":") + resourceSlug := parts[5] + names = append(names, fmt.Sprintf( + "%s: %s", + resourceSlug, + translationFileTask.languageCode, + )) + } + fmt.Printf("Pushed translations: %s\n", strings.Join(names, ", ")) + } } return nil @@ -211,7 +272,10 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { args := task.args targetLanguagesChannel := task.targetLanguagesChannel - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } send(fmt.Sprintf( "%s.%s - %s", cfgResource.ProjectSlug, @@ -219,10 +283,10 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { body, )) } - sendMessage("Getting info") + sendMessage("Getting info", false) resource, err := txapi.GetResourceById(api, cfgResource.GetAPv3Id()) if err != nil { - sendMessage(fmt.Sprintf("Error while fetching resource: %s", err)) + sendMessage(fmt.Sprintf("Error while fetching resource: %s", err), true) if !args.Skip { abort() } @@ -233,17 +297,18 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { if resourceIsNew { if args.Translation && !args.Source { sendMessage( - "You are attempting to push translations for a resource that doesn't " + + "You are attempting to push translations for a resource that doesn't "+ "exist yet", + true, ) if !args.Skip { abort() } return } - sendMessage("Resource does not exist; creating") + sendMessage("Resource does not exist; creating", false) if cfgResource.Type == "" { - sendMessage("Error: Cannot create resource, i18n type is unknown") + sendMessage("Error: Cannot create resource, i18n type is unknown", true) if !args.Skip { abort() } @@ -270,7 +335,7 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { cfgResource.ResourceSlug, cfgResource.Type) if err != nil { - sendMessage(fmt.Sprintf("Error while creating resource, %s", err)) + sendMessage(fmt.Sprintf("Error while creating resource, %s", err), true) if !args.Skip { abort() } @@ -278,10 +343,10 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { } } - sendMessage("Getting stats") + sendMessage("Getting stats", false) projectRelationship, err := resource.Fetch("project") if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -291,8 +356,9 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { sourceLanguageRelationship, exists := project.Relationships["source_language"] if !exists { sendMessage( - "Invalid API response, project does not have a 'source_language' " + + "Invalid API response, project does not have a 'source_language' "+ "relationship", + true, ) if !args.Skip { abort() @@ -307,7 +373,7 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { remoteStats, err = txapi.GetResourceStats(api, resource, sourceLanguage) } if err != nil { - sendMessage(fmt.Sprintf("Error while fetching stats, %s", err)) + sendMessage(fmt.Sprintf("Error while fetching stats, %s", err), true) if !args.Skip { abort() } @@ -330,10 +396,10 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { ) overrides := cfgResource.Overrides - sendMessage("Fetching remote languages") + sendMessage("Fetching remote languages", false) curDir, err := os.Getwd() if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -342,7 +408,7 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { fileFilter := cfgResource.FileFilter err = checkFileFilter(fileFilter) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -357,7 +423,7 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { remoteStats, overrides, args, resourceIsNew, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -366,7 +432,7 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { allLanguages, err := txapi.GetLanguages(api) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) abort() return } @@ -394,21 +460,26 @@ func (task *ResourcePushTask) Run(send func(string), abort func()) { } } } - sendMessage("Done") + sendMessage("Done", false) } type LanguagePushTask struct { project *jsonapi.Resource languages []string + args PushCommandArguments } func (task *LanguagePushTask) Run(send func(string), abort func()) { project := task.project languages := task.languages + args := task.args parts := strings.Split(project.Id, ":") - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } send(fmt.Sprintf( "%s (%s) - %s", parts[3], @@ -416,7 +487,7 @@ func (task *LanguagePushTask) Run(send func(string), abort func()) { body, )) } - sendMessage("Pushing") + sendMessage("Pushing", false) var payload []*jsonapi.Resource for _, language := range languages { @@ -427,12 +498,12 @@ func (task *LanguagePushTask) Run(send func(string), abort func()) { } err := project.Add("languages", payload) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) abort() return } - sendMessage("Done") + sendMessage("Done", false) } type SourceFilePushTask struct { @@ -453,13 +524,16 @@ func (task *SourceFilePushTask) Run(send func(string), abort func()) { resourceIsNew := task.resourceIsNew parts := strings.Split(resource.Id, ":") - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } send(fmt.Sprintf("%s.%s - %s", parts[3], parts[5], body)) } file, err := os.Open(sourceFile) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -474,11 +548,11 @@ func (task *SourceFilePushTask) Run(send func(string), abort func()) { sourceFile, remoteStats, args.UseGitTimestamps, ) if skip { - sendMessage("Skipping") + sendMessage("Skipping", false) return } if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -496,10 +570,10 @@ func (task *SourceFilePushTask) Run(send func(string), abort func()) { return err }, "Uploading file", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -513,17 +587,17 @@ func (task *SourceFilePushTask) Run(send func(string), abort func()) { return txapi.PollSourceUpload(sourceUpload, time.Second) }, "", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } - sendMessage("Done") + sendMessage("Done", false) } type TranslationFileTask struct { @@ -547,7 +621,10 @@ func (task *TranslationFileTask) Run(send func(string), abort func()) { parts := strings.Split(resource.Id, ":") cyan := color.New(color.FgCyan).SprintFunc() - sendMessage := func(body string) { + sendMessage := func(body string, force bool) { + if args.Silent && !force { + return + } send(fmt.Sprintf( "%s.%s %s - %s", parts[3], parts[5], cyan("["+languageCode+"]"), body, @@ -561,14 +638,14 @@ func (task *TranslationFileTask) Run(send func(string), abort func()) { if exists { skip, err := shouldSkipPush(path, remoteStat, args.UseGitTimestamps) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } if skip { - sendMessage("Skipping because remote file is newer than local") + sendMessage("Skipping because remote file is newer than local", false) return } } @@ -586,10 +663,10 @@ func (task *TranslationFileTask) Run(send func(string), abort func()) { return err }, "Uploading file", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } @@ -602,16 +679,16 @@ func (task *TranslationFileTask) Run(send func(string), abort func()) { return txapi.PollTranslationUpload(upload, time.Second) }, "", - sendMessage, + func(msg string) { sendMessage(msg, false) }, ) if err != nil { - sendMessage(err.Error()) + sendMessage(err.Error(), true) if !args.Skip { abort() } return } - sendMessage("Done") + sendMessage("Done", false) } func getFilesToPush( diff --git a/pkg/worker_pool/main.go b/pkg/worker_pool/main.go index 222d97a..5f86876 100644 --- a/pkg/worker_pool/main.go +++ b/pkg/worker_pool/main.go @@ -125,21 +125,23 @@ type message_t struct { } type Pool struct { - numWorkers int - numTasks int - taskChannel chan taskContainer_t - innerWaitGroup sync.WaitGroup - outerWaitGroup sync.WaitGroup - counter int + numWorkers int + numTasks int + taskChannel chan taskContainer_t + innerWaitGroup sync.WaitGroup + outerWaitGroup sync.WaitGroup + counter int + forceNotTerminal bool IsAborted bool } -func New(numWorkers, numTasks int) *Pool { +func New(numWorkers, numTasks int, forceNotTerminal bool) *Pool { var pool Pool pool.numWorkers = numWorkers pool.numTasks = numTasks pool.taskChannel = make(chan taskContainer_t, numTasks) + pool.forceNotTerminal = forceNotTerminal return &pool } @@ -153,7 +155,7 @@ func (pool *Pool) Start() { messages := make([]string, pool.numTasks+1) messageChannel := make(chan message_t) writer := uilive.New() - if isatty.IsTerminal(os.Stdout.Fd()) { + if !pool.forceNotTerminal && isatty.IsTerminal(os.Stdout.Fd()) { writer.Start() } pool.outerWaitGroup.Add(1) @@ -169,7 +171,7 @@ func (pool *Pool) Start() { } taskContainer.task.Run(send, pool.abort) } - if isatty.IsTerminal(os.Stdout.Fd()) { + if !pool.forceNotTerminal && isatty.IsTerminal(os.Stdout.Fd()) { atomic.AddInt32(&finishedTasks, 1) messageChannel <- message_t{ pool.numTasks, @@ -203,7 +205,7 @@ func (pool *Pool) Start() { for !exitfor { select { case msg := <-messageChannel: - if isatty.IsTerminal(os.Stdout.Fd()) { + if !pool.forceNotTerminal && isatty.IsTerminal(os.Stdout.Fd()) { messages[msg.i] = msg.body printMessages() } else { @@ -211,7 +213,7 @@ func (pool *Pool) Start() { } case <-waitChannel: exitfor = true - if isatty.IsTerminal(os.Stdout.Fd()) { + if !pool.forceNotTerminal && isatty.IsTerminal(os.Stdout.Fd()) { writer.Stop() } close(messageChannel) @@ -220,7 +222,7 @@ func (pool *Pool) Start() { } }() - if isatty.IsTerminal(os.Stdout.Fd()) { + if !pool.forceNotTerminal && isatty.IsTerminal(os.Stdout.Fd()) { messageChannel <- message_t{ pool.numTasks, makeProgressBar(finishedTasks, pool.numTasks),