Skip to content

Commit d9eda83

Browse files
committed
feat(cli): assign short option -o to report file
1 parent 6daa810 commit d9eda83

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ go install dbohdan.com/recur/v3@latest
4545
<!-- BEGIN USAGE -->
4646
```none
4747
Usage: recur [-h] [-V] [-a <attempts>] [-b <backoff>] [-c <condition>] [-d
48-
<delay>] [-E] [-F] [-f] [-I] [-j <jitter>] [-m <max-delay>] [-O] [-R <format>]
49-
[--report-file <path>] [-r <reset-time>] [-s <seed>] [-t <timeout>] [-v] [--]
50-
<command> [<arg> ...]
48+
<delay>] [-E] [-F] [-f] [-I] [-j <jitter>] [-m <max-delay>] [-O] [-o <path>] [-R
49+
<format>] [-r <reset-time>] [-s <seed>] [-t <timeout>] [-v] [--] <command>
50+
[<arg> ...]
5151
5252
Retry a command with exponential backoff and jitter.
5353
@@ -100,12 +100,12 @@ Fibonacci backoff (duration)
100100
-O, --hold-stdout
101101
Buffer standard output for each attempt and only print it on success
102102
103+
-o, --report-file "-"
104+
Report output file path ("-" for stderr)
105+
103106
-R, --report "none"
104107
Report format ("none", "json", or "text")
105108
106-
--report-file "-"
107-
Report output file path ("-" for stderr)
108-
109109
-r, --reset -1s
110110
Minimum attempt time that resets exponential and Fibonacci backoff
111111
(duration; negative for no reset)

main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func wrapForTerm(s string) string {
480480

481481
func usage(w io.Writer) {
482482
s := fmt.Sprintf(
483-
`Usage: %s [-h] [-V] [-a <attempts>] [-b <backoff>] [-c <condition>] [-d <delay>] [-E] [-F] [-f] [-I] [-j <jitter>] [-m <max-delay>] [-O] [-R <format>] [--report-file <path>] [-r <reset-time>] [-s <seed>] [-t <timeout>] [-v] [--] <command> [<arg> ...]`,
483+
`Usage: %s [-h] [-V] [-a <attempts>] [-b <backoff>] [-c <condition>] [-d <delay>] [-E] [-F] [-f] [-I] [-j <jitter>] [-m <max-delay>] [-O] [-o <path>] [-R <format>] [-r <reset-time>] [-s <seed>] [-t <timeout>] [-v] [--] <command> [<arg> ...]`,
484484
filepath.Base(os.Args[0]),
485485
)
486486

@@ -541,12 +541,12 @@ Options:
541541
-O, --hold-stdout
542542
Buffer standard output for each attempt and only print it on success
543543
544+
-o, --report-file %q
545+
Report output file path ("-" for stderr)
546+
544547
-R, --report %q
545548
Report format ("none", "json", or "text")
546549
547-
--report-file %q
548-
Report output file path ("-" for stderr)
549-
550550
-r, --reset %v
551551
Minimum attempt time that resets exponential and Fibonacci backoff (duration; negative for no reset)
552552
@@ -565,8 +565,8 @@ Options:
565565
formatDuration(delayDefault),
566566
jitterDefault,
567567
formatDuration(maxDelayDefault),
568-
reportDefault,
569568
reportFileDefault,
569+
reportDefault,
570570
formatDuration(resetDefault),
571571
randomSeedDefault,
572572
formatDuration(timeoutDefault),
@@ -703,6 +703,9 @@ func parseArgs() retryConfig {
703703
case "-O", "--hold-stdout":
704704
config.HoldStdout = true
705705

706+
case "-o", "--report-file":
707+
config.ReportFile = nextArg(arg)
708+
706709
case "-E", "--hold-stderr":
707710
config.HoldStderr = true
708711

@@ -746,9 +749,6 @@ func parseArgs() retryConfig {
746749

747750
config.Report = reportFormat
748751

749-
case "--report-file":
750-
config.ReportFile = nextArg(arg)
751-
752752
// "-v" is handled in the default case.
753753
case "--verbose":
754754
config.Verbose++

main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ func TestReportJSON(t *testing.T) {
717717
}
718718

719719
func TestReportText(t *testing.T) {
720-
_, stderr, _ := runCommand("-R", "text", "-a", "3", "-c", "False", commandExit99)
720+
_, stderr, _ := runCommand("-R", "text", "-o", "-", "-a", "3", "-c", "False", commandExit99)
721721

722722
for _, text := range []string{"attempts: 3", "Exit codes: 99, 99, 99"} {
723723
if !strings.Contains(stderr, text) {

0 commit comments

Comments
 (0)