55 "log"
66 "os"
77 "os/signal"
8+ "path/filepath"
89 "syscall"
910
1011 "github.com/go-task/task/v2"
1819 version = "master"
1920)
2021
21- const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [--summary] [task...]
22+ const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--taskfile] [-- dry] [--summary] [task...]
2223
2324Runs the specified task(s). Falls back to the "default" task if no task name
2425was specified, or lists all tasks if an unknown task name was specified.
@@ -59,6 +60,7 @@ func main() {
5960 dry bool
6061 summary bool
6162 dir string
63+ entrypoint string
6264 output string
6365 color bool
6466 )
@@ -74,6 +76,7 @@ func main() {
7476 pflag .BoolVar (& dry , "dry" , false , "compiles and prints tasks in the order that they would be run, without executing them" )
7577 pflag .BoolVar (& summary , "summary" , false , "show summary about a task" )
7678 pflag .StringVarP (& dir , "dir" , "d" , "" , "sets directory of execution" )
79+ pflag .StringVarP (& entrypoint , "taskfile" , "t" , "" , `choose which Taskfile to run. Defaults to "Taskfile.yml"` )
7780 pflag .StringVarP (& output , "output" , "o" , "" , "sets output style: [interleaved|group|prefixed]" )
7881 pflag .BoolVarP (& color , "color" , "c" , true , "colored output" )
7982 pflag .Parse ()
@@ -94,15 +97,27 @@ func main() {
9497 return
9598 }
9699
100+ if dir != "" && entrypoint != "" {
101+ log .Fatal ("task: You can't set both --dir and --taskfile" )
102+ return
103+ }
104+ if entrypoint != "" {
105+ dir = filepath .Dir (entrypoint )
106+ entrypoint = filepath .Base (entrypoint )
107+ } else {
108+ entrypoint = "Taskfile.yml"
109+ }
110+
97111 e := task.Executor {
98- Force : force ,
99- Watch : watch ,
100- Verbose : verbose ,
101- Silent : silent ,
102- Dir : dir ,
103- Dry : dry ,
104- Summary : summary ,
105- Color : color ,
112+ Force : force ,
113+ Watch : watch ,
114+ Verbose : verbose ,
115+ Silent : silent ,
116+ Dir : dir ,
117+ Dry : dry ,
118+ Entrypoint : entrypoint ,
119+ Summary : summary ,
120+ Color : color ,
106121
107122 Stdin : os .Stdin ,
108123 Stdout : os .Stdout ,
0 commit comments