1
0
mirror of https://github.com/go-task/task.git synced 2025-01-06 03:53:54 +02:00

feat: experiments flag (#1242)

This commit is contained in:
Pete Davison 2023-06-30 02:29:28 +01:00 committed by GitHub
parent 02f1c8482a
commit 46f7bba90d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View File

@ -10,6 +10,8 @@
@sounisi5011). @sounisi5011).
- Added the [gentle force experiment](https://taskfile.dev/experiments) as a - Added the [gentle force experiment](https://taskfile.dev/experiments) as a
draft (#1200, #1216 by @pd93). draft (#1200, #1216 by @pd93).
- Added an `--experiments` flag to allow you to see which experiments are
enabled (#1242 by @pd93).
- Added ability to specify which variables are required in a task (#1203, #1204 - Added ability to specify which variables are required in a task (#1203, #1204
by @benc-uk). by @benc-uk).

View File

@ -70,6 +70,7 @@ var flags struct {
color bool color bool
interval time.Duration interval time.Duration
global bool global bool
experiments bool
} }
func main() { func main() {
@ -129,6 +130,7 @@ func run() error {
pflag.IntVarP(&flags.concurrency, "concurrency", "C", 0, "Limit number tasks to run concurrently.") pflag.IntVarP(&flags.concurrency, "concurrency", "C", 0, "Limit number tasks to run concurrently.")
pflag.DurationVarP(&flags.interval, "interval", "I", 0, "Interval to watch for changes.") pflag.DurationVarP(&flags.interval, "interval", "I", 0, "Interval to watch for changes.")
pflag.BoolVarP(&flags.global, "global", "g", false, "Runs global Taskfile, from $HOME/{T,t}askfile.{yml,yaml}.") pflag.BoolVarP(&flags.global, "global", "g", false, "Runs global Taskfile, from $HOME/{T,t}askfile.{yml,yaml}.")
pflag.BoolVar(&flags.experiments, "experiments", false, "Lists all the available experiments and whether or not they are enabled.")
// Gentle force experiment will override the force flag and add a new force-all flag // Gentle force experiment will override the force flag and add a new force-all flag
if experiments.GentleForce { if experiments.GentleForce {
@ -150,6 +152,16 @@ func run() error {
return nil return nil
} }
if flags.experiments {
l := &logger.Logger{
Stdout: os.Stdout,
Stderr: os.Stderr,
Verbose: flags.verbose,
Color: flags.color,
}
return experiments.List(l)
}
if flags.init { if flags.init {
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {

View File

@ -5,8 +5,11 @@ import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
"text/tabwriter"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/go-task/task/v3/internal/logger"
) )
const envPrefix = "TASK_X_" const envPrefix = "TASK_X_"
@ -41,3 +44,11 @@ func readDotEnv() error {
} }
return nil return nil
} }
func List(l *logger.Logger) error {
w := tabwriter.NewWriter(os.Stdout, 0, 8, 6, ' ', 0)
l.FOutf(w, logger.Yellow, "* ")
l.FOutf(w, logger.Green, "GENTLE_FORCE")
l.FOutf(w, logger.Default, ": \t%t\n", GentleForce)
return w.Flush()
}