cron

package module
v0.0.0-...-353315b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 5 Imported by: 0

README

Please don't use this. This was a take-home task for a full-time software engineering position at a food delivery company that is headquartered in London, UK. Sounds a bit like deliver a roo.


basic-cron-parser

GoDoc

basic-cron-parser is a package for Go that allows you parse cron expressions.

Supported features:

  • expressions must consist of five "parts" followed by a command.
  • asterisk (*)
  • basic slashes, for some time interval x (e.g. `*/15)
    • note that this includes the smallest value, and you are expected to provide intervals that evenly divide
  • basic commas (e.g. 1,2)
  • hyphens (e.g. 1-7)

Unsupported features:

This repository is an experiment. In practice, you should use robfig's cron library.

Installation

Install using go get github.com/qaisjp/basic-cron-parser/cmd/expr-parser.

If you have $GOPATH/bin in your $PATH, you should be able to run expr-parser.

Otherwise, you can do something like go run github.com/qaisjp/basic-cron-parser/cmd/expr-parser "*/15 0 1,15 * 1-5 /usr/bin/find arg1 arg2".

Usage

expr-parser [CRON_EXPRESSION]

expr-parser takes a single argument, CRON_EXPRESSION, which is a cron string like "*/15 0 1,15 * 1-5 /usr/bin/find -L . -print0".

Documentation

Index

Constants

View Source
const (
	MinMinutes = 0
	MaxMinutes = 59

	MinHours = 0
	MaxHours = 23

	MinDayOfMonth = 1
	MaxDayOfMonth = 31

	MinMonths = 1
	MaxMonths = 12

	MinDayOfWeek = 0
	MaxDayOfWeek = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CronExpression

type CronExpression struct {
	Minutes    []string
	Hours      []string
	DayOfMonth []string
	Months     []string
	DayOfWeek  []string
	Command    string
}

CronExpression represents a parsed cron spec

func NewCronExpression

func NewCronExpression(str string) (*CronExpression, error)

NewCronExpression creates a CronExpression given a string

func (CronExpression) String

func (e CronExpression) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL