@@ -11,40 +11,44 @@ import (
1111)
1212
1313const (
14- InfoColor = "\033 [1;34m%s\033 [0m%s"
15- NoticeColor = "\033 [1;36m%s\033 [0m%s"
16- WarningColor = "\033 [1;33m%s\033 [0m%s"
17- ErrorColor = "\033 [1;31m%s\033 [0m%s"
14+ // ErrorColor colors the first text red and the second text default color
15+ ErrorColor = "\033 [1;31m%s\033 [0m%s"
16+ // SuccessColor colors the first text green and the second text default color
1817 SuccessColor = "\033 [1;32m%s\033 [0m%s"
19- DebugColor = "\033 [0;36m%s\033 [0m%s"
2018)
2119
20+ // TaskOptions is a configuration used to define the behaviour of tasks and processing functions
2221type TaskOptions struct {
2322 Text string
2423 Execute func (wg * sync.WaitGroup , results chan TaskResult )
2524}
2625
26+ // TaskResult is the result of a task execution and expected to be returned into the respective channel
2727type TaskResult struct {
2828 // internal name
2929 Name string
3030 Message string
3131 Error bool
3232}
3333
34+ // Text assigns the given text to TaskOption.Text
3435func Text (text string ) TaskOption {
3536 return func (args * TaskOptions ) {
3637 args .Text = text
3738 }
3839}
3940
41+ // Execute assigns the given execution function to TaskOption.Execute
4042func Execute (executeFunc func (wg * sync.WaitGroup , results chan TaskResult )) TaskOption {
4143 return func (args * TaskOptions ) {
4244 args .Execute = executeFunc
4345 }
4446}
4547
48+ // TaskOption is a single task setting
4649type TaskOption func (* TaskOptions )
4750
51+ // RunTask executes a task that can be configured using task options
4852func RunTask (options ... TaskOption ) {
4953 t := & TaskOptions {
5054 Text : "Processing..." ,
0 commit comments