getconfig in pttodo-cli
parent
20770ff5e6
commit
0bd6347a93
2
go.mod
2
go.mod
|
|
@ -5,7 +5,6 @@ go 1.17
|
|||
require (
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
local/sandbox/contact/contact v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
@ -15,4 +14,3 @@ require (
|
|||
golang.org/x/text v0.3.7 // indirect
|
||||
)
|
||||
|
||||
replace local/sandbox/contact/contact => ../sandbox/contact/contact
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
package pttodo
|
||||
|
||||
/*
|
||||
action is something like 'send an email on trigger' but is not impl or use
|
||||
*/
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"local/sandbox/contact/contact"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type Action string
|
||||
|
||||
var (
|
||||
actionEmailPattern = regexp.MustCompile(`[^@]+@.*[^\.]+\.[a-z]+`)
|
||||
)
|
||||
|
||||
func (action Action) String() string {
|
||||
return string(action)
|
||||
}
|
||||
|
||||
func (action Action) CB() (func() error, error) {
|
||||
u, _ := url.Parse(action.String())
|
||||
switch u.Scheme {
|
||||
case "email":
|
||||
return action.email, nil
|
||||
}
|
||||
if actionEmailPattern.MatchString(action.String()) {
|
||||
return action.email, nil
|
||||
}
|
||||
return nil, errors.New("unrecognized action")
|
||||
}
|
||||
|
||||
func (action Action) email() error {
|
||||
em := contact.NewEmailer()
|
||||
_ = em
|
||||
return errors.New("not impl")
|
||||
}
|
||||
Loading…
Reference in New Issue