@@ -12,22 +12,13 @@ import (
1212 "syscall"
1313 "time"
1414
15- "github.com/nxtcoder17/go.pkgs/log"
16- "github.com/nxtcoder17/runfile/errors"
17- "github.com/nxtcoder17/runfile/runner"
18- "github.com/nxtcoder17/runfile/types"
19-
20- "github.com/nxtcoder17/runfile/parser"
15+ "github.com/nxtcoder17/fastlog"
16+ "github.com/nxtcoder17/runfile/pkg/errors"
17+ "github.com/nxtcoder17/runfile/pkg/runfile"
2118 "github.com/urfave/cli/v3"
2219)
2320
24- var Version string = fmt .Sprintf ("nightly | %s" , time .Now ().Format (time .RFC3339 ))
25-
26- var runfileNames []string = []string {
27- "Runfile" ,
28- "Runfile.yml" ,
29- "Runfile.yaml" ,
30- }
21+ var Version string
3122
3223//go:embed completions/run.fish
3324var shellCompletionFISH string
@@ -42,6 +33,10 @@ var shellCompletionZSH string
4233var shellCompletionPS string
4334
4435func main () {
36+ if Version == "" {
37+ Version = fmt .Sprintf ("nightly | %s" , time .Now ().Format (time .RFC3339 ))
38+ }
39+
4540 cmd := cli.Command {
4641 Name : "run" ,
4742 Version : Version ,
@@ -190,9 +185,11 @@ func main() {
190185 return fmt .Errorf ("parallel and watch can't be set together" )
191186 }
192187
193- logger := log .New (log.Options {
194- ShowCaller : true ,
195- ShowLogLevel : true ,
188+ logger := fastlog .New (fastlog.Options {
189+ Format : fastlog .ConsoleFormat ,
190+ EnableColors : true ,
191+ ShowCaller : debug ,
192+ ShowTimestamp : false ,
196193 ShowDebugLogs : debug ,
197194 })
198195
@@ -202,32 +199,22 @@ func main() {
202199 return err
203200 }
204201
205- runfileCtx := types .NewContext (ctx , logger )
202+ rctx := runfile .NewContext (ctx , logger )
206203
207- rf , err2 := parser . ParseRunfile ( runfileCtx , runfilePath )
208- if err2 != nil {
209- slog .Error ("parsing runfile, got" , "err" , err2 )
210- panic (err2 )
204+ rf , err := runfile . ParseFromFile ( rctx , runfilePath )
205+ if err != nil {
206+ slog .Error ("parsing runfile, got" , "err" , err )
207+ panic (err )
211208 }
212209
213- if err := runner .Run (runfileCtx , rf , runner.RunArgs {
214- Tasks : args ,
210+ if err := rf .Run (rctx , args , runfile.RunOption {
215211 ExecuteInParallel : parallel ,
216212 Watch : watch ,
217213 Debug : debug ,
218214 KVs : kv ,
219215 }); err != nil {
220- errm , ok := err .(* errors.Error )
221- slog .Debug ("got" , "err" , err )
222- if ok {
223- if errm != nil {
224- // errm.Error()
225- // TODO: change it to a better logging
226- // slog.Error("got", "err", errm)
227- errm .Log ()
228- }
229- } else {
230- slog .Error ("got" , "err" , err )
216+ if err2 , ok := err .(* errors.Error ); ok {
217+ logger .Error (err2 .Error (), err2 .SlogAttrs ()... )
231218 }
232219 }
233220
@@ -260,6 +247,12 @@ func locateRunfile(c *cli.Command) (string, error) {
260247
261248 oldDir := ""
262249
250+ runfileNames := []string {
251+ "Runfile" ,
252+ "Runfile.yml" ,
253+ "Runfile.yaml" ,
254+ }
255+
263256 for oldDir != dir {
264257 for _ , fn := range runfileNames {
265258 if _ , err := os .Stat (filepath .Join (dir , fn )); err != nil {
0 commit comments