Skip to content

Commit

Permalink
feat: --limit=0 to disable limit
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Mar 19, 2023
1 parent 27009c2 commit 3780fc9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {
var opt = Option{}

cli := pflag.NewFlagSet("try", pflag.ContinueOnError)
cli.UintVar(&opt.Limit, "limit", 5, "max retry")
cli.UintVar(&opt.Limit, "limit", 5, "max retry, set limit to 0 to disable limit")
cli.DurationVar(&opt.Delay, "delay", time.Millisecond*100, "retry delay")
flags, cmd := partitionCommand(os.Args[1:])
if len(cmd) == 0 {
Expand Down Expand Up @@ -42,10 +42,6 @@ type Option struct {
}

func (o Option) Retry(cmd string, args []string) error {
if o.Limit <= 0 {
o.Limit = 3
}

return retry.Do(
func() error {
c := exec.Command(cmd, args...)
Expand Down

0 comments on commit 3780fc9

Please sign in to comment.