From d3c4af33bf4b9f7891415873960b3e526fed7b99 Mon Sep 17 00:00:00 2001 From: x1ah Date: Tue, 17 Nov 2020 20:21:02 +0800 Subject: [PATCH] add alfred-cron workflow --- cmd/cron/main.go | 18 +++++++++++++++- go.mod | 5 +++++ go.sum | 41 ++++++++++++++++++++++++++++++++++++ icon.png | Bin 0 -> 11731 bytes main.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 go.sum create mode 100644 icon.png create mode 100644 main.go diff --git a/cmd/cron/main.go b/cmd/cron/main.go index 10cdcde..aac9143 100644 --- a/cmd/cron/main.go +++ b/cmd/cron/main.go @@ -1,5 +1,21 @@ package main +import ( + "fmt" + "time" + + "github.com/robfig/cron/v3" +) + func main() { - println("hello cron") + parser := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow) + s, err := parser.Parse("1 * * * *") + if err != nil { + panic(err) + } + curr := time.Now() + for i := 0; i <= 10; i++ { + curr = s.Next(curr) + fmt.Println(curr) + } } diff --git a/go.mod b/go.mod index 7a2a3f5..434629d 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,8 @@ module github.com/x1ah/alfred-cron go 1.14 + +require ( + github.com/deanishe/awgo v0.27.1 + github.com/robfig/cron/v3 v3.0.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5207776 --- /dev/null +++ b/go.sum @@ -0,0 +1,41 @@ +github.com/bmatcuk/doublestar v1.3.1/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deanishe/awgo v0.27.1 h1:Vf8v7yaGWN3fibT+db1Mfw95Q/rD/1Qbf4ahGa4tMSY= +github.com/deanishe/awgo v0.27.1/go.mod h1:Qen3509y1/sj7a5syefWc6FQHO1LE/tyoTyN9jRv1vU= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g= +github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.deanishe.net/env v0.5.1 h1:WiOncK5uJj8Um57Vj2dc1bq1lMN7fgRag9up7I3LZy0= +go.deanishe.net/env v0.5.1/go.mod h1:ihEYfDm0K0hq3f5ACTCQDrMTWxH9fTiA1lh1i0aMqm0= +go.deanishe.net/fuzzy v1.0.0 h1:3Qp6PCX0DLb9z03b5OHwAGsbRSkgJpSLncsiDdXDt4Y= +go.deanishe.net/fuzzy v1.0.0/go.mod h1:2yEEMfG7jWgT1s5EO0TteVWmx2MXFBRMr5cMm84bQNY= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ea52e9b90e771f847f5b7370723a8008e402af65 GIT binary patch literal 11731 zcmXwT7p(&XYmorOo#O6pDelFKQ?$4TcZy4(6!+pminqACdvTWn#ocb+@80_( zIcsDj<0L!h?6u}IXVgbkIm|aCZvX%Qrh>e*2K+eq-vbQ={#^N~DhB|d0w_p>wY-c^ zjL_4_v>RU3u1CX^n}y#7i+0@txj};%E!bfBX8O;m+EI*|Z;0eQQC*O7hjG2s2=EII z|C+vg7gY+@;!g~-DDS~VlSZ`oK!vx%bO-!EWhADMmR@z)zMTFg(#Y3C_qy=(c2}xH z=yt{J#UOCK+;>7OV)6?nkOVD_MiSGW1dSKODVGO^_Rma7b|MC&fJqYMkp4SNNFpIP zq4DZ~oPP27oY122qSby=cJEPvzlOGj*(6(?4TQf9k`(3m>kt!OwQkNIG<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Jis8WxA2H z!$`ySGv%v_7u}e@@R{tXE1MOEXKu7}TAyIDECM|)Dekb)PXvw7(MhvGX%G1%a21F4 z3xMRIJVvsZ#|4qp4}^9~LT7%zGT>uU`Y*D})(J%WNtARcoCpy!1fvGs;TIk&yaL8p zOD%(>;6Y_-{(MZ&5E*!7dT#%P)C?X+=I*7h-&FkxuW(s&Fdd{Y;Eg7HF^qo&od8~i z^ws4%M8f09gP_dGaFH$=c=P$`#b1xf1rH_@o8c`vGkk(q=mZntjnv_tuShiee1o{Y Ty;bnAHb6l}Rl4efX~_QpopobG literal 0 HcmV?d00001 diff --git a/main.go b/main.go new file mode 100644 index 0000000..c495c98 --- /dev/null +++ b/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "strings" + "time" + + aw "github.com/deanishe/awgo" + "github.com/robfig/cron/v3" +) + +// AlfredCron alfred-cron struct +type AlfredCron struct { + wf *aw.Workflow + // how many times + repeated int + cronParser cron.Parser +} + +// NewAlfredCron create new AlfredCron instance +func NewAlfredCron() *AlfredCron { + return &AlfredCron{ + wf: aw.New(), + repeated: 7, + cronParser: cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow), + } +} + +// Run run alfred-cron workflow +func (ac *AlfredCron) Run() { + spec := strings.Join(ac.wf.Args(), "") + if spec == "" { + ac.wf.NewItem("no crontab expression found.").Subtitle("Try input a crontab expression?") + ac.wf.SendFeedback() + return + } + + expr, err := ac.cronParser.Parse(spec) + if err != nil { + ac.wf.NewWarningItem("Invalid expression", err.Error()) + } else { + curr := time.Now() + for i := 0; i < ac.repeated; i++ { + curr = expr.Next(curr) + ac.wf.NewItem(curr.String()) + } + } + ac.wf.SendFeedback() +} + +func main() { + alfredCron := NewAlfredCron() + alfredCron.Run() +}