all repos — erl @ ad8f97f9fb886a7c2e7ef7ef8a738ae7f0c9ddf5

Execute Reload Loop

feat: add quiet flag

Alan Pearce
commit

ad8f97f9fb886a7c2e7ef7ef8a738ae7f0c9ddf5

parent

921c8f0ae3eec6acf4f3cfb236f3a7f0869006e9

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

changed files
M main.gomain.go
@@ -3,6 +3,7 @@
import ( "context" "flag" + "io" "log" "os" "os/signal"
@@ -20,7 +21,8 @@ "alin.ovh/erl/watcher"
) var ( - Exec = flag.String("exec", "", "command to execute on file change") + Exec = flag.String("exec", "", "command to execute on file change") + Quiet = flag.Bool("quiet", false, "suppress own output") ) func Start(ctx context.Context, w watcher.Watcher, sm *state.StateMachine) {
@@ -128,7 +130,12 @@ syscall.SIGTERM,
) defer cancel() - cmd := command.New(program, args, command.Options{}) + copts := command.Options{} + if *Quiet { + copts.Output = io.Discard + } + + cmd := command.New(program, args, copts) sm := state.New(cmd, log.New(os.Stderr, "state: ", log.Lmsgprefix)) Start(ctx, watcher, sm) }