all repos — erl @ 9ff79186f294e5afbcae44da09be054c8636b61b

Execute Reload Loop

feat: set default program to `go run .`

Alan Pearce
commit

9ff79186f294e5afbcae44da09be054c8636b61b

parent

c8ab7c849959313a035bf9e448d110e794190a4f

1 file changed, 10 insertions(+), 2 deletions(-)

changed files
M main.gomain.go
@@ -6,6 +6,7 @@ "flag"
"log" "os" "os/signal" + "slices" "strings" "sync" "syscall"
@@ -102,8 +103,15 @@ log.SetFlags(log.Lmsgprefix)
flag.Parse() program := *Exec + args := flag.Args() if program == "" { - log.Fatal("no command provided") + program = "go" + + if len(args) == 0 { + args = []string{"run", "."} + } else { + args = slices.Insert(args, 0, "run") + } } watcher, err := watcher.New()
@@ -120,7 +128,7 @@ syscall.SIGTERM,
) defer cancel() - cmd := command.New(program, flag.Args(), command.Options{}) + cmd := command.New(program, args, command.Options{}) sm := state.New(cmd, log.New(os.Stderr, "state: ", log.Lmsgprefix)) Start(ctx, watcher, sm) }