diff --git a/cmd/task/task.go b/cmd/task/task.go index 969cb956..ea60a709 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -14,7 +14,7 @@ var ( version = "master" ) -const usage = `Usage: task [-ifw] [--init] [--force] [--watch] [task...] +const usage = `Usage: task [-ifwv] [--init] [--force] [--watch] [--verbose] [task...] Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was specified. @@ -45,12 +45,14 @@ func main() { init bool force bool watch bool + verbose bool ) pflag.BoolVar(&versionFlag, "version", false, "show Task version") pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder") pflag.BoolVarP(&force, "force", "f", false, "forces execution even when the task is up-to-date") pflag.BoolVarP(&watch, "watch", "w", false, "enables watch of the given task") + pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode") pflag.Parse() if versionFlag { @@ -70,8 +72,9 @@ func main() { } e := task.Executor{ - Force: force, - Watch: watch, + Force: force, + Watch: watch, + Verbose: verbose, Stdin: os.Stdin, Stdout: os.Stdout, diff --git a/log.go b/log.go index e5ee75b8..e8b070a1 100644 --- a/log.go +++ b/log.go @@ -11,3 +11,15 @@ func (e *Executor) println(args ...interface{}) { func (e *Executor) printfln(format string, args ...interface{}) { fmt.Fprintf(e.Stdout, format+"\n", args...) } + +func (e *Executor) verbosePrintln(args ...interface{}) { + if e.Verbose { + e.println(args...) + } +} + +func (e *Executor) verbosePrintfln(format string, args ...interface{}) { + if e.Verbose { + e.printfln(format, args...) + } +} diff --git a/task.go b/task.go index ab4e5960..19caa2e7 100644 --- a/task.go +++ b/task.go @@ -21,10 +21,11 @@ const ( // Executor executes a Taskfile type Executor struct { - Tasks Tasks - Dir string - Force bool - Watch bool + Tasks Tasks + Dir string + Force bool + Watch bool + Verbose bool Stdin io.Reader Stdout io.Writer diff --git a/variable_handling.go b/variable_handling.go index 5a6ab0a7..8d18e671 100644 --- a/variable_handling.go +++ b/variable_handling.go @@ -45,6 +45,7 @@ func (e *Executor) handleDynamicVariableContent(value string) (string, error) { } result = strings.TrimSpace(result) + e.verbosePrintfln(`task: dynamic variable: "%s", result: "%s"`, value, result) return result, nil }