MCPcopy Create free account
hub / github.com/github/gh-aw / parseShortDurationInterval

Method parseShortDurationInterval

pkg/parser/schedule_parser.go:141–165  ·  view source on GitHub ↗
(hasWeekdaysSuffix bool)

Source from the content-addressed store, hash-verified

139}
140
141func (p *ScheduleParser) parseShortDurationInterval(hasWeekdaysSuffix bool) (string, bool, error) {
142 if !p.usesShortDurationSyntax(hasWeekdaysSuffix) {
143 return "", false, nil
144 }
145
146 matches := durationPattern.FindStringSubmatch(p.tokens[1])
147 if matches == nil {
148 return "", false, nil
149 }
150
151 interval, err := strconv.Atoi(matches[1])
152 if err != nil {
153 return "", true, fmt.Errorf("invalid duration interval %q: %w", matches[1], err)
154 }
155 unit := matches[2]
156 if err := p.validateIntervalTimeClause(2, hasWeekdaysSuffix); err != nil {
157 return "", true, err
158 }
159 if err := validateMinimumInterval(interval, unit); err != nil {
160 return "", true, err
161 }
162
163 cronExpr, err := formatShortDurationCron(interval, unit, hasWeekdaysSuffix)
164 return cronExpr, true, err
165}
166
167func (p *ScheduleParser) usesShortDurationSyntax(hasWeekdaysSuffix bool) bool {
168 return len(p.tokens) == 2 ||

Callers 1

parseIntervalMethod · 0.95

Calls 5

validateMinimumIntervalFunction · 0.85
formatShortDurationCronFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected