-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser options #75
Parser options #75
Conversation
Does #73 meet your need? If not, can you describe the use case for creating a non-standard parser? It seems like having some kind of semi-standard syntax is a big benefit, and changing the set of stuff accepted would be fairly confusing if it didn't enable some significant new use case. That being said, it does look cool to configure the parser like that! |
We use it to omit the time options since we don't use them. We store a schedule associated with a subscription and scheduled the next date. We also added some non-standard options (like week of year) that was needed to accomplish a bi-weekly schedule. You could keep the function in #73 by passing a different set of options, much like how I presented Parse above. There are also a couple parser options that make some fields optional or required (like day of week). I have some other features built on the parser options branch described in #69. |
8a52a7b
to
470ac64
Compare
@robfig I've brought this up to date with master.
Which looks almost exactly like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just the two exported types should have godoc
// - Descriptors, e.g. "@midnight", "@every 1h30m" | ||
func Parse(spec string) (Schedule, error) { | ||
if spec[0] == '@' { | ||
type Parser struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc please
if standardSpec[0] == '@' { | ||
return parseDescriptor(standardSpec) | ||
} | ||
type ParseOption int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc please
a50be17
to
edf8e83
Compare
godocs added. Also fixed golint warning complaining about an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thank you!!
Parse options https://github.com/webconnex/cron/tree/parser-options
This adds
Parser
andNewParser
with the ability to:Select which fields are included. So you can exclude seconds, or any other field you don't want to use.
Set other options that might be useful, like making certain assumptions about the schedule.
The Parse function now looks like this:
This could be a resolution for Cron Format not the same as Cron Spec #58. All you would need to do is remove
Second
and it would be spec compliant. But for those who need it, they can create a new parser with the option.I'm not sure about Dow being optional and being "spec complaint" - but there are two options for this -
Dow
andDowOptional
which are interchangeable - one makes it required, the other allows you to omit it.(See #69)