Added parser options: DefaultDuration
I've added a defautl duration as required for my usecase.
It changes the signature to the Parse function but by using vargs it shouldn't impact any existing usage. I have extended the test cases to match too.
A futher extension I would consider for my use-case is: DisableCustomDuration to force the default duration. (Or perhaps it would be "ForceDuration?")
I haven't found a "great" way of doing opt args for options. This is typically how I do it. I have also seen people use it as an internal struct modifier ie:
type Opts struct {
defautlDuration *time.Duration
}
type ParserOpt interface {
Apply(o *Opts) error
}
type DefaultDuration time.Duration
func (dd DefaultDuration) Apply(o *Opts) error {
var t time.Duration = time.Duration(dd)
o.defaultDuration = &t
return nil
}
...
for _ opt := range opts { opt.apply(&opts) }
...
Fixed other deepsource issues in other PR. https://github.com/1set/cronrange/pull/17 if both merged there should be no issue
Merge conflict resolved.