From bf7f87940ebd5356324169f495ac8d02c7ed235b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:34:58 +0000 Subject: [PATCH 1/3] Initial plan From badbd539df8634a9810f1a515793ddf3789148a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:40:52 +0000 Subject: [PATCH 2/3] Add verbose flag and progress reporting functionality Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com> --- waitfor/main.go | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/waitfor/main.go b/waitfor/main.go index 7b06f90..f7fc324 100644 --- a/waitfor/main.go +++ b/waitfor/main.go @@ -11,6 +11,7 @@ import ( "github.com/go-waitfor/waitfor-proc" "github.com/urfave/cli/v2" "os" + "time" ) var version string @@ -48,6 +49,11 @@ func main() { EnvVars: []string{"WAITFOR_MAX_INTERVAL"}, Value: 60, }, + &cli.BoolFlag{ + Name: "verbose", + Usage: "enable verbose progress output", + EnvVars: []string{"WAITFOR_VERBOSE"}, + }, }, Action: func(ctx *cli.Context) error { if ctx.NArg() == 0 { @@ -77,12 +83,42 @@ func main() { program.Args = args[1:] } - out, err := runner.Run( - ctx.Context, - program, + // Build waitfor options + options := []waitfor.Option{ waitfor.WithAttempts(ctx.Uint64("attempts")), waitfor.WithInterval(ctx.Uint64("interval")), waitfor.WithMaxInterval(ctx.Uint64("max-interval")), + } + + // If verbose mode is enabled, show progress + if ctx.Bool("verbose") { + fmt.Printf("waitfor: checking %d resource(s) with %d max attempts\n", len(program.Resources), ctx.Uint64("attempts")) + for i, resource := range program.Resources { + fmt.Printf("waitfor: [%d/%d] checking %s\n", i+1, len(program.Resources), resource) + } + fmt.Printf("waitfor: retry interval: %ds, max interval: %ds\n", ctx.Uint64("interval"), ctx.Uint64("max-interval")) + fmt.Println("waitfor: starting resource availability tests...") + + start := time.Now() + + // Test resources first to show progress + err := runner.Test(ctx.Context, program.Resources, options...) + + duration := time.Since(start) + + if err != nil { + fmt.Printf("waitfor: resource tests failed after %v: %v\n", duration.Round(time.Millisecond), err) + return err + } + + fmt.Printf("waitfor: all resources available after %v\n", duration.Round(time.Millisecond)) + fmt.Printf("waitfor: executing command: %s\n", program.Executable) + } + + out, err := runner.Run( + ctx.Context, + program, + options..., ) if out != nil { From 08ddcd24d652616f4d06666506ced20ef6b7f465 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:42:32 +0000 Subject: [PATCH 3/3] Update documentation for verbose flag Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com> --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 8077dfa..7b48d7e 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,17 @@ export WAITFOR_MAX_INTERVAL=30 waitfor npm start ``` +### Verbose Output +Enable detailed progress information during resource checks: +```bash +# Show progress information while waiting for resources +waitfor --verbose -r postgres://localhost:5432/db -r http://localhost:8080 npm start + +# Or use environment variable +export WAITFOR_VERBOSE=true +waitfor -r http://localhost:8080 ./start-app.sh +``` + ## Configuration ### Command Line Options @@ -112,6 +123,7 @@ waitfor npm start | `--attempts` | `-a` | Number of connection attempts | `5` | `WAITFOR_ATTEMPTS` | | `--interval` | - | Initial interval between attempts (seconds) | `5` | `WAITFOR_INTERVAL` | | `--max-interval` | - | Maximum interval between attempts (seconds) | `60` | `WAITFOR_MAX_INTERVAL` | +| `--verbose` | - | Enable verbose progress output | `false` | `WAITFOR_VERBOSE` | | `--help` | `-h` | Show help | - | - | | `--version` | `-v` | Show version | - | - | @@ -134,6 +146,7 @@ GLOBAL OPTIONS: --attempts value, -a value amount of attempts (default: 5) [$WAITFOR_ATTEMPTS] --interval value interval between attempts (sec) (default: 5) [$WAITFOR_INTERVAL] --max-interval value maximum interval between attempts (sec) (default: 60) [$WAITFOR_MAX_INTERVAL] + --verbose enable verbose progress output (default: false) [$WAITFOR_VERBOSE] --help, -h show help (default: false) --version, -v print the version (default: false)