feat: add quiet flag
1 file changed, 9 insertions(+), 2 deletions(-)
changed files
M main.go → main.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) }