@@ -17,7 +17,6 @@ import (
1717 "github.com/go-task/task/v3/internal/filepathext"
1818 "github.com/go-task/task/v3/internal/flags"
1919 "github.com/go-task/task/v3/internal/logger"
20- "github.com/go-task/task/v3/internal/sort"
2120 ver "github.com/go-task/task/v3/internal/version"
2221 "github.com/go-task/task/v3/taskfile"
2322 "github.com/go-task/task/v3/taskfile/ast"
@@ -57,9 +56,6 @@ func run() error {
5756 return err
5857 }
5958
60- dir := flags .Dir
61- entrypoint := flags .Entrypoint
62-
6359 if flags .Version {
6460 fmt .Printf ("Task version: %s\n " , ver .GetVersionWithSum ())
6561 return nil
@@ -113,61 +109,15 @@ func run() error {
113109 return nil
114110 }
115111
116- if flags .Global {
117- home , err := os .UserHomeDir ()
118- if err != nil {
119- return fmt .Errorf ("task: Failed to get user home directory: %w" , err )
120- }
121- dir = home
122- }
123-
124112 if err := experiments .Validate (); err != nil {
125113 log .Warnf ("%s\n " , err .Error ())
126114 }
127115
128- var taskSorter sort.Sorter
129- switch flags .TaskSort {
130- case "none" :
131- taskSorter = nil
132- case "alphanumeric" :
133- taskSorter = sort .AlphaNumeric
134- }
135-
136- e := task.Executor {
137- Dir : dir ,
138- Entrypoint : entrypoint ,
139- Force : flags .Force ,
140- ForceAll : flags .ForceAll ,
141- Insecure : flags .Insecure ,
142- Download : flags .Download ,
143- Offline : flags .Offline ,
144- Timeout : flags .Timeout ,
145- Watch : flags .Watch ,
146- Verbose : flags .Verbose ,
147- Silent : flags .Silent ,
148- AssumeYes : flags .AssumeYes ,
149- Dry : flags .Dry || flags .Status ,
150- Summary : flags .Summary ,
151- Parallel : flags .Parallel ,
152- Color : flags .Color ,
153- Concurrency : flags .Concurrency ,
154- Interval : flags .Interval ,
155-
156- Stdin : os .Stdin ,
157- Stdout : os .Stdout ,
158- Stderr : os .Stderr ,
159-
160- OutputStyle : flags .Output ,
161- TaskSorter : taskSorter ,
162- EnableVersionCheck : true ,
163- }
164- listOptions := task .NewListOptions (flags .List , flags .ListAll , flags .ListJson , flags .NoStatus )
165- if err := listOptions .Validate (); err != nil {
166- return err
167- }
168-
169- err := e .Setup ()
170- if err != nil {
116+ e := task .NewExecutor (
117+ flags .WithExecutorOptions (),
118+ task .ExecutorWithVersionCheck (true ),
119+ )
120+ if err := e .Setup (); err != nil {
171121 return err
172122 }
173123
@@ -185,11 +135,16 @@ func run() error {
185135 return cache .Clear ()
186136 }
187137
188- if (listOptions .ShouldListTasks ()) && flags .Silent {
189- return e .ListTaskNames (flags .ListAll )
190- }
191-
138+ listOptions := task .NewListOptions (
139+ flags .List ,
140+ flags .ListAll ,
141+ flags .ListJson ,
142+ flags .NoStatus ,
143+ )
192144 if listOptions .ShouldListTasks () {
145+ if flags .Silent {
146+ return e .ListTaskNames (flags .ListAll )
147+ }
193148 foundTasks , err := e .ListTasks (listOptions )
194149 if err != nil {
195150 return err
0 commit comments