Skip to content

Commit 4960209

Browse files
authored
Merges PR #39
2 parents a377474 + a0e8ff4 commit 4960209

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3133
-2167
lines changed

Runfile.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tasks:
1010
cmd:
1111
- |+
1212
echo "building ..."
13-
go build -o bin/run -ldflags="-s -w" -tags urfave_cli_no_docs ./cmd/run
13+
go build -o bin/run-nightly -ldflags="-s -w" -tags urfave_cli_no_docs ./cmd/run
1414
echo "DONE"
1515
1616
example:
@@ -38,12 +38,12 @@ tasks:
3838
cmd:
3939
- |+
4040
pattern_args=""
41-
[ -n "$pattern" ] && pattern_args="-run '$pattern'"
41+
[ -n "$pattern" ] && pattern_args="-run $pattern"
4242
4343
testfmt_args=""
4444
[ "$only_failing" = "true" ] && testfmt_args="--hide successful-tests"
4545
46-
go test -json ./parser/... $pattern_args | gotestfmt $testfmt_args
46+
go test -json ./pkg/runfile/... $pattern_args | gotestfmt $testfmt_args
4747
4848
test:only-failing:
4949
cmd:

cmd/run/completions.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"io"
77
"log/slog"
88

9-
"github.com/nxtcoder17/go.pkgs/log"
10-
"github.com/nxtcoder17/runfile/parser"
11-
"github.com/nxtcoder17/runfile/types"
9+
"github.com/nxtcoder17/fastlog"
10+
"github.com/nxtcoder17/runfile/pkg/runfile"
1211
)
1312

1413
func generateShellCompletion(ctx context.Context, writer io.Writer, rfpath string) error {
15-
runfile, err := parser.ParseRunfile(types.NewContext(ctx, log.New()), rfpath)
14+
runfile, err := runfile.ParseFromFile(runfile.NewContext(ctx, fastlog.New()), rfpath)
1615
if err != nil {
1716
slog.Error("parsing, got", "err", err)
1817
panic(err)

cmd/run/main.go

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3324
var shellCompletionFISH string
@@ -42,6 +33,10 @@ var shellCompletionZSH string
4233
var shellCompletionPS string
4334

4435
func 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 {

errors/errors.go

Lines changed: 0 additions & 178 deletions
This file was deleted.

flake.nix

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
description = "RunFile dev workspace";
3-
43
inputs = {
54
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
65
};
76

8-
outputs = { self, nixpkgs, flake-utils }:
9-
flake-utils.lib.eachDefaultSystem (system:
10-
let
11-
pkgs = import nixpkgs { inherit system; };
12-
in
13-
{
7+
outputs = {
8+
self,
9+
nixpkgs,
10+
flake-utils,
11+
}:
12+
flake-utils.lib.eachDefaultSystem (
13+
system: let
14+
pkgs = import nixpkgs {inherit system;};
15+
in {
1416
devShells.default = pkgs.mkShell {
1517
# hardeningDisable = [ "all" ];
1618

@@ -36,5 +38,3 @@
3638
}
3739
);
3840
}
39-
40-

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/charmbracelet/lipgloss v1.0.0
1010
github.com/joho/godotenv v1.5.1
1111
github.com/muesli/termenv v0.15.2
12+
github.com/nxtcoder17/fastlog v0.0.0-20250702035423-1739653a5c24
1213
github.com/nxtcoder17/fwatcher v1.2.2-0.20250318121757-bfc2065fa9f5
1314
github.com/nxtcoder17/go.pkgs v0.0.0-20250216034729-39e2d2cd48da
1415
github.com/urfave/cli/v3 v3.0.0-beta1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T
3737
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
3838
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
3939
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
40+
github.com/nxtcoder17/fastlog v0.0.0-20250702035423-1739653a5c24 h1:oLLpFv1p7jRRrrsZzyf77pECLAMKrTxzHRSoHNRoELw=
41+
github.com/nxtcoder17/fastlog v0.0.0-20250702035423-1739653a5c24/go.mod h1:x6o+8WEHRGaWu9XEhSdTrjmDjKhVnKNXd/XZ56bNN/o=
4042
github.com/nxtcoder17/fwatcher v1.2.2-0.20250318121757-bfc2065fa9f5 h1:6BulIAQBv2FZqUFZcKtFEhc1vMOeOdeMS+S5d874FMY=
4143
github.com/nxtcoder17/fwatcher v1.2.2-0.20250318121757-bfc2065fa9f5/go.mod h1:SMwIdCpyi5fBygrkCX8hIIUeILzgoxJFaDSlhFBOWWQ=
4244
github.com/nxtcoder17/go.pkgs v0.0.0-20250216034729-39e2d2cd48da h1:Y6GILHFlrihVfDqDPQ98y2kdUeI0SQc8tnoXh2NbEIA=

0 commit comments

Comments
 (0)